+ Reply to Thread
Results 1 to 2 of 2

Referencing a sheet name

Hybrid View

westonkw Referencing a sheet name 05-23-2008, 10:29 AM
Rick_Stanich If the sheets will remain in... 05-23-2008, 11:35 AM
  1. #1
    Registered User
    Join Date
    02-28-2008
    Posts
    36

    Referencing a sheet name

    When you are writing code you can reference a sheet by "Sheet1" or by its name at the bottom of the workbook on the tabs. The "Sheet1" ref. always stays with the sheet but the name at the bottom can be changed and it screws up the code if the sheet gets renamed.

    Im trying to reference a sheet in a formula by the "Sheet1" name, is this possible? I cant get it to work. I need to do this because I have a macro that add sheets when the user needs them, and they also rename them, usually the date. Then in the certain situation it gives me a ref error in theses cells when the sheet is renamed. If the "Sheet1" reference would work in the formula this would take care of the problem.

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,179
    If the sheets will remain in the same order of precedence then try "Sheets(1)" in place of "Sheets("Sheet1")" and so on.
    Example:
    MsgBox Sheets(1).Range("A1").Value
    Will display the value in cell A1 of the first work sheet.
    Regards

    Rick
    Win10, Office 365

+ 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