+ Reply to Thread
Results 1 to 3 of 3

Renaming sheet with VBA

  1. #1
    Barb Reinhardt
    Guest

    Renaming sheet with VBA

    I am doing some checks for specific text within the existing sheet name and
    if the sheet name contains that value, I want to rename it to include
    information from named range abc.

    I'm using this to rename the sheet

    Worksheets(i).Name = "TRY IT " & Range("abc") & " - Cover
    Page"

    I know I've got the right worksheet, but it's not being renamed. Does the
    formula need to be changed?

    Thanks,
    Barb Reinhardt

  2. #2
    Chip Pearson
    Guest

    Re: Renaming sheet with VBA

    Barb,

    Where is the code located? It should be in a regular code module,
    not in a sheet module or the ThisWorkbook module. If you have it
    in a sheet object module, you need to qualify the Range statement
    to point to the sheet on which the range "abc" is defined. E.g,.

    Worksheets(i).Name = _
    "TRY IT " & Worksheets(1).Range("abc") & " - Cover Page """


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Barb Reinhardt" <[email protected]> wrote
    in message
    news:[email protected]...
    >I am doing some checks for specific text within the existing
    >sheet name and
    > if the sheet name contains that value, I want to rename it to
    > include
    > information from named range abc.
    >
    > I'm using this to rename the sheet
    >
    > Worksheets(i).Name = "TRY IT " & Range("abc") &
    > " - Cover
    > Page"
    >
    > I know I've got the right worksheet, but it's not being
    > renamed. Does the
    > formula need to be changed?
    >
    > Thanks,
    > Barb Reinhardt




  3. #3
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333

    Arrow

    I used this code to rename all the sheets in an active workbook. I had to set up the named range on EACH sheet and use a different value in each so that the name would not be duplicated.

    Please Login or Register  to view this content.



    Quote Originally Posted by Barb Reinhardt
    I am doing some checks for specific text within the existing sheet name and
    if the sheet name contains that value, I want to rename it to include
    information from named range abc.

    I'm using this to rename the sheet

    Worksheets(i).Name = "TRY IT " & Range("abc") & " - Cover
    Page"

    I know I've got the right worksheet, but it's not being renamed. Does the
    formula need to be changed?

    Thanks,
    Barb Reinhardt
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

+ 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