+ Reply to Thread
Results 1 to 6 of 6

Rename a sheet

  1. #1
    Registered User
    Join Date
    08-25-2004
    Posts
    82

    Rename a sheet

    I have a workbook that references different sheets with the command

    Sheets(1).Select

    Problem is this sheet somehow no longer exists in my workbook.

    When i get to this line in my code it errors out because the sheet does not exist. Is there a way to rename one of my other sheets, say Sheet2 to be Sheets(1)

    Any help is great.

    Green

  2. #2
    Registered User
    Join Date
    08-25-2004
    Posts
    82
    hmm now that im looking at this, how is it even possible that Sheets(1).Select returns an error? isnt it always there because it is a reference to the sheets in a workbook?

  3. #3
    Registered User
    Join Date
    08-25-2004
    Posts
    82
    I just found this from a vba developers site

    "Index Number
    A sheets Index number is determined by its position in the Workbook. The left most sheet will always have an Index number of 1, the next on the right will be 2 and so on. Excel VBA allows us to specify any Sheet by using it's Index number, but unfortunately this method is not used by Excel when we record a macro. It uses the Sheets Tab name like; Sheets("Budget").Select If this sheet was the third from the left we could use: Sheets(3).Select. This is often a better option than using the sheet tab name, but still has potential problems. By this I mean, the sheets position in the Workbook could change if we add, remove or move sheets."

    how is it possible that Sheet(1) does not exist in my program?

  4. #4
    Tom Ogilvy
    Guest

    Re: Rename a sheet

    1 is an idex number indicating the first sheet in the tab order if all
    sheets are visible. Possibly, you have made the first sheet hidden, so it
    can't be selected.

    --
    Regards,
    Tom Ogilvy

    "greenfalcon" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I have a workbook that references different sheets with the command
    >
    > Sheets(1).Select
    >
    > Problem is this sheet somehow no longer exists in my workbook.
    >
    > When i get to this line in my code it errors out because the sheet does
    > not exist. Is there a way to rename one of my other sheets, say Sheet2
    > to be Sheets(1)
    >
    > Any help is great.
    >
    > Green
    >
    >
    > --
    > greenfalcon
    > ------------------------------------------------------------------------
    > greenfalcon's Profile:

    http://www.excelforum.com/member.php...o&userid=13622
    > View this thread: http://www.excelforum.com/showthread...hreadid=391859
    >




  5. #5
    Tom Ogilvy
    Guest

    Re: Rename a sheet

    It isn't possible that it doesn't exist. It is possible that you can't
    select it.

    --
    Regards,
    Tom Ogilvy

    "greenfalcon" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I just found this from a vba developers site
    >
    > "Index Number
    > A sheets Index number is determined by its position in the Workbook.
    > The left most sheet will always have an Index number of 1, the next on
    > the right will be 2 and so on. Excel VBA allows us to specify any Sheet
    > by using it's Index number, but unfortunately this method is not used by
    > Excel when we record a macro. It uses the Sheets Tab name like;
    > Sheets("Budget").Select If this sheet was the third from the left we
    > could use: Sheets(3).Select. This is often a better option than using
    > the sheet tab name, but still has potential problems. By this I mean,
    > the sheets position in the Workbook could change if we add, remove or
    > move sheets."
    >
    > how is it possible that Sheet(1) does not exist in my program?
    >
    >
    > --
    > greenfalcon
    > ------------------------------------------------------------------------
    > greenfalcon's Profile:

    http://www.excelforum.com/member.php...o&userid=13622
    > View this thread: http://www.excelforum.com/showthread...hreadid=391859
    >




  6. #6
    Registered User
    Join Date
    08-25-2004
    Posts
    82
    hehe, Shortly after i made my final post i checked a computer with the problem, you were correct in that the sheet in question was hidden. I had forgotten about that. Thanks for your help

    Jason

+ 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