+ Reply to Thread
Results 1 to 6 of 6

how do i create a macro to rename worksheets in excel?

  1. #1
    Waki
    Guest

    how do i create a macro to rename worksheets in excel?

    I have a list of loan numbers that I want to use to rename worksheet tabs,
    any way to do that?

  2. #2
    Pank Mehta
    Guest

    RE: how do i create a macro to rename worksheets in excel?

    I have used the following previously:-
    Sub Rename()
    Sheets("old name").Select
    Sheets("old name").Name = "new name"
    End Sub

    Hope this helps

    "Waki" wrote:

    > I have a list of loan numbers that I want to use to rename worksheet tabs,
    > any way to do that?


  3. #3
    Waki
    Guest

    RE: how do i create a macro to rename worksheets in excel?

    Thanks, but I'm new to VB...I'm going to need a little more help.

    "Pank Mehta" wrote:

    > I have used the following previously:-
    > Sub Rename()
    > Sheets("old name").Select
    > Sheets("old name").Name = "new name"
    > End Sub
    >
    > Hope this helps
    >
    > "Waki" wrote:
    >
    > > I have a list of loan numbers that I want to use to rename worksheet tabs,
    > > any way to do that?


  4. #4
    JulieD
    Guest

    Re: how do i create a macro to rename worksheets in excel?

    Hi Waki

    the first approach assumes that you don't have the sheets in your workbook
    yet and will add the sheet in and name it from your list of loan numbers
    ....(instructions on using the code are at the bottom)
    Assuming your loan numbers are in the range A2:A10 inclusive
    Sub newws()
    Dim arr As Variant
    arr = Range("a2:a10").Value
    For i = LBound(arr) To UBound(arr)
    Set NewSheet = Sheets.Add
    NewSheet.Name = arr(i, 1)
    Next i
    End Sub

    --------- this second option assumes that you have all the sheets in the
    workbook and you want to name them as per the list in A2:A10

    Sub namesheets()
    Dim arr As Variant
    arr = Range("a2:a10").Value
    For i = LBound(arr) To UBound(arr)
    Sheets(i + 1).Activate
    Sheets(i).Name = arr(i,1)
    Next i
    End Sub

    -------

    to use either of the above, right mouse click on a sheet tab and choose view
    code
    this will display the VBE Window
    choose insert / module from the menu and you'll get a piece of white paper
    on the right hand side of the screen
    copy and paste the code above from the word sub to the words end sub into
    the right hand side of the screen
    press ALT & F11 to return to your workbook
    ensure your loan numbers are in cells A2:A10 of the sheet you're viewing and
    choose tools / macro / macros from the menu
    choose either namesheets or newws as appropriate and click on the run button

    hope this helps
    Cheers
    JulieD

    "Waki" <[email protected]> wrote in message
    news:[email protected]...
    >I have a list of loan numbers that I want to use to rename worksheet tabs,
    > any way to do that?




  5. #5
    Waki
    Guest

    Re: how do i create a macro to rename worksheets in excel?

    Thanks!!!!!

    "JulieD" wrote:

    > Hi Waki
    >
    > the first approach assumes that you don't have the sheets in your workbook
    > yet and will add the sheet in and name it from your list of loan numbers
    > ....(instructions on using the code are at the bottom)
    > Assuming your loan numbers are in the range A2:A10 inclusive
    > Sub newws()
    > Dim arr As Variant
    > arr = Range("a2:a10").Value
    > For i = LBound(arr) To UBound(arr)
    > Set NewSheet = Sheets.Add
    > NewSheet.Name = arr(i, 1)
    > Next i
    > End Sub
    >
    > --------- this second option assumes that you have all the sheets in the
    > workbook and you want to name them as per the list in A2:A10
    >
    > Sub namesheets()
    > Dim arr As Variant
    > arr = Range("a2:a10").Value
    > For i = LBound(arr) To UBound(arr)
    > Sheets(i + 1).Activate
    > Sheets(i).Name = arr(i,1)
    > Next i
    > End Sub
    >
    > -------
    >
    > to use either of the above, right mouse click on a sheet tab and choose view
    > code
    > this will display the VBE Window
    > choose insert / module from the menu and you'll get a piece of white paper
    > on the right hand side of the screen
    > copy and paste the code above from the word sub to the words end sub into
    > the right hand side of the screen
    > press ALT & F11 to return to your workbook
    > ensure your loan numbers are in cells A2:A10 of the sheet you're viewing and
    > choose tools / macro / macros from the menu
    > choose either namesheets or newws as appropriate and click on the run button
    >
    > hope this helps
    > Cheers
    > JulieD
    >
    > "Waki" <[email protected]> wrote in message
    > news:[email protected]...
    > >I have a list of loan numbers that I want to use to rename worksheet tabs,
    > > any way to do that?

    >
    >
    >


  6. #6
    JulieD
    Guest

    Re: how do i create a macro to rename worksheets in excel?

    you're welcome and thanks for the feedback

    "Waki" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks!!!!!
    >
    > "JulieD" wrote:
    >
    >> Hi Waki
    >>
    >> the first approach assumes that you don't have the sheets in your
    >> workbook
    >> yet and will add the sheet in and name it from your list of loan numbers
    >> ....(instructions on using the code are at the bottom)
    >> Assuming your loan numbers are in the range A2:A10 inclusive
    >> Sub newws()
    >> Dim arr As Variant
    >> arr = Range("a2:a10").Value
    >> For i = LBound(arr) To UBound(arr)
    >> Set NewSheet = Sheets.Add
    >> NewSheet.Name = arr(i, 1)
    >> Next i
    >> End Sub
    >>
    >> --------- this second option assumes that you have all the sheets in the
    >> workbook and you want to name them as per the list in A2:A10
    >>
    >> Sub namesheets()
    >> Dim arr As Variant
    >> arr = Range("a2:a10").Value
    >> For i = LBound(arr) To UBound(arr)
    >> Sheets(i + 1).Activate
    >> Sheets(i).Name = arr(i,1)
    >> Next i
    >> End Sub
    >>
    >> -------
    >>
    >> to use either of the above, right mouse click on a sheet tab and choose
    >> view
    >> code
    >> this will display the VBE Window
    >> choose insert / module from the menu and you'll get a piece of white
    >> paper
    >> on the right hand side of the screen
    >> copy and paste the code above from the word sub to the words end sub into
    >> the right hand side of the screen
    >> press ALT & F11 to return to your workbook
    >> ensure your loan numbers are in cells A2:A10 of the sheet you're viewing
    >> and
    >> choose tools / macro / macros from the menu
    >> choose either namesheets or newws as appropriate and click on the run
    >> button
    >>
    >> hope this helps
    >> Cheers
    >> JulieD
    >>
    >> "Waki" <[email protected]> wrote in message
    >> news:[email protected]...
    >> >I have a list of loan numbers that I want to use to rename worksheet
    >> >tabs,
    >> > any way to do that?

    >>
    >>
    >>




+ 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