+ Reply to Thread
Results 1 to 9 of 9

Referencing worksheet with changing worksheet name

  1. #1
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Referencing worksheet with changing worksheet name

    Hello, I am running into a problem.
    I have a worksheet that has a changing name that is open initially, users change it frequently.
    I run a macros that goes to a second worksheet.
    I would like to go back to the previous worksheet with the changing name and copy data in it to another sheet. I was wondering how I can reference the worksheet in a macros that was initially open since the name changes

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Referencing worksheet with changing worksheet name

    Use it's code name ?

    see: http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm

  3. #3
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Referencing worksheet with changing worksheet name

    How would I give a code name to the active sheet?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Referencing worksheet with changing worksheet name

    read the link provided - the code name is predefined.

  5. #5
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Referencing worksheet with changing worksheet name

    Unfortunately, i didnt specify before, but the sheet one is initially can also change as well/ renamed. Thus i am not sure how the code name will help me. I would like to call upon whatever sheet I am initially opened in when running a macros so I can come back to it. If there is someway for me to assign a value to the initial active sheet, and call upon this later, that would be ideal
    Last edited by undergraduate; 03-26-2010 at 10:56 AM.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Referencing worksheet with changing worksheet name

    I can't follow what you're doing at all I'm afraid as the goalposts appear to have been moved.

    If you need to store the "ActiveSheet" at run time then store as a Worksheet object

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Referencing worksheet with changing worksheet name

    Thank you, and now with that in order for me to select the previous activesheet how do I do it?
    Instead of Sheets("1").Select
    If I do wsactive.select or sheets(wsactive).select it does not work, once i figure that out my question has been resolved. thank you.

  8. #8
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Referencing worksheet with changing worksheet name

    It says just with
    Please Login or Register  to view this content.
    that object is required. why is that?

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Referencing worksheet with changing worksheet name

    Because you need ActiveSheet rather than ActiveWorksheet.
    To activate it again at the end use:
    Please Login or Register  to view this content.
    Note also that it is almost never necessary to activate or select anything in code.
    Remember what the dormouse said
    Feed your head

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1