Consulting

Results 1 to 3 of 3

Thread: Solved: Refering Sheet without using Sheet name in VBA Code

  1. #1

    Solved: Refering Sheet without using Sheet name in VBA Code

    Hi All,
    How do we refer to sheets without using Sheetnames while developing the code in VBA.

    For e.g., I have Sheet1 and Sheet2 with button macros. While developing the code, i have used sheetname as reference.
    Requirement is if we copy Sheet1 and name as sheet3, though the logic is perfect since the sheet name in the code was Sheet1 will not work for Sheet3.

    Can anyone help me in resolving how to point to the sheet without using Sheets("sheet1").....
    Vineela

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    If you can be certain of the order in which the sheets will occur, you could use Sheets(1), Sheets(2), etc. Alternatively, if the code has to be run against the active sheet, you could use 'ActiveSheet'.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Thank you so much. Working as per intended after using "ActiveSheet".

    Regards,
    Vineela

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •