Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Renaming / Resorting Sheet Tabs via VBA__Perfect! Than

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Guys.
    Board search is not working.

    How do I do this?
    Any example will do...
    Thanks,
    Tom

    [ This Message was edited by: TsTom on 2002-03-27 09:21 ]

  2. #2
    MrExcel MVP Joe Was's Avatar
    Join Date
    Feb 2002
    Location
    Central Florida, USA
    Posts
    7,539
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sub mySheetData()
    '
    'By Joe Was

    'This adds a sheet and names it "Test."
    Sheets.Add.Name = "Test"

    'This selects your new sheet and moves it after sheet "Sheet3," which could be any sheet name.
    Sheets("Test").Select
    Sheets("Test").Move After:=Sheets("Sheet3")

    'this selects the sheet with the data and its range.
    Sheets("Sheet1").Select
    Range("A1:A7").Select

    'This will copy and paste the data to your new sheet "Test."
    Selection.Copy
    Sheets("Test").Select
    ActiveSheet.Paste

    'At this point your data will be on the new sheet and selected for the next step.

    End Sub

    This askes the user for a new sheet name and makes the new sheet.

    Sub IBoxSheet()
    Dim mySheet As String
    'This code asks the user for a new Sheet name.
    'Then makes a new Sheet with the users inputed name.

    mySheet = Application.InputBox(prompt:="Enter the name of your new Sheet: ", Title:="Add Sheet!", Type:=1 + 2)
    Sheets.Add.Name = mySheet
    End Sub


    Hope this helps. JSW

    [ This Message was edited by: Joe Was on 2002-05-29 19:26 ]

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Houston, TX
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    To rename a worksheet, change it's Name property.

    wks.Name = "New Name"

    As far as sorting is concerned, there is no easy way that I know of (at least in 97, not real firm on 2000/2002).

    You will have to manually loop through all the sheets and create a sorted list of names (in an array?) then use the .Move method of the worksheet to move them before/after the proper sheets. I would guess that it's a good bit of code.

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Renaming

    Sheets("Sheet1").Name = "Bob"

    Resorting

    Sheets("Bob").Select
    Sheets("Bob").Move After:=Sheets(3) 'moving sheet "Bob" after the third sheet

    HTH

    Matt


Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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