+ Reply to Thread
Results 1 to 9 of 9

naming tabs

  1. #1
    Jeff
    Guest

    naming tabs

    is there a simple way to have a tab on a worksheet the same as text in a
    cell on that sheet ??

  2. #2

    Re: naming tabs

    The following will work for Sheet1 with the tab name in cell A1.

    Paste the following code into the code section of Sheet1:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    sName = Sheets(1).Range("A1")
    If sName = "" Then sName = "Sheet1"
    Sheets(1).Name = sName
    End Sub


  3. #3
    Jeff
    Guest

    Re: naming tabs

    [email protected] wrote:
    > The following will work for Sheet1 with the tab name in cell A1.
    >
    > Paste the following code into the code section of Sheet1:
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > sName = Sheets(1).Range("A1")
    > If sName = "" Then sName = "Sheet1"
    > Sheets(1).Name = sName
    > End Sub
    >

    excuse my ignorance but what do you mean by "code section"

  4. #4

    Re: naming tabs

    Click on Tools - Macro - Visual Basic Editor

    On the left should be a VBAProject Window. Expand the items listed
    until you see Sheet1 (Sheet1). Double Click on Sheet1. A VBA Code
    Window will open for Sheet1.

    I hope this will help get you started.


  5. #5
    Paul B
    Guest

    Re: naming tabs

    Jeff,
    To put in this macro right click on the worksheet tab and view code, in the
    window that opens paste this code, press Alt and Q to close this window and
    go back to your workbook. If you are using excel 2000 or newer you may have
    to change the macro security settings to get the macro to run. To change the
    security settings go to tools, macro, security, security level and set it to
    medium

    The code that was posted will work if your sheet is the first sheet in the
    workbook, if not you may want to try this

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
    If Target.Value <> "" Then
    On Error Resume Next
    ActiveSheet.Name = Target.Value
    On Error GoTo 0
    End If
    End If

    End Sub



    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "Jeff" <[email protected]> wrote in message
    news:[email protected]...
    > [email protected] wrote:
    > > The following will work for Sheet1 with the tab name in cell A1.
    > >
    > > Paste the following code into the code section of Sheet1:
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > > sName = Sheets(1).Range("A1")
    > > If sName = "" Then sName = "Sheet1"
    > > Sheets(1).Name = sName
    > > End Sub
    > >

    > excuse my ignorance but what do you mean by "code section"




  6. #6
    Jeff
    Guest

    Re: naming tabs

    [email protected] wrote:
    > Click on Tools - Macro - Visual Basic Editor
    >
    > On the left should be a VBAProject Window. Expand the items listed
    > until you see Sheet1 (Sheet1). Double Click on Sheet1. A VBA Code
    > Window will open for Sheet1.
    >
    > I hope this will help get you started.
    >

    Thanks very much that was great just what I needed to do.

    next querie if I may
    can you make the colour of the text or number in a cell change if a
    certain criteria is met ??

  7. #7
    Jeff
    Guest

    Re: naming tabs

    Paul B wrote:
    > Jeff,
    > To put in this macro right click on the worksheet tab and view code, in the
    > window that opens paste this code, press Alt and Q to close this window and
    > go back to your workbook. If you are using excel 2000 or newer you may have
    > to change the macro security settings to get the macro to run. To change the
    > security settings go to tools, macro, security, security level and set it to
    > medium
    >
    > The code that was posted will work if your sheet is the first sheet in the
    > workbook, if not you may want to try this
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > If Target.Address = "$A$1" Then
    > If Target.Value <> "" Then
    > On Error Resume Next
    > ActiveSheet.Name = Target.Value
    > On Error GoTo 0
    > End If
    > End If
    >
    > End Sub
    >
    >
    >

    Paul, this also works well thank you, can you advise me of a way of
    using this or another formula to enable me to rename all sheets in a
    work book ?? do I need to place this formula in all worksheets using the
    VB editor ??

  8. #8

    Re: naming tabs

    Yes Click on Format - Conditional Formatting...

    >From here you can set the condition.



  9. #9
    Paul B
    Guest

    Re: naming tabs

    Jeff, if you want to change all the sheets at one time try this

    Sub Rename_All_Sheets()
    'will rename all sheets in the workbook to the value in A1
    Dim WS As Worksheet
    For Each WS In Worksheets
    WS.Name = WS.Range("A1").Value
    Next
    End Sub
    To put in this macro, from your workbook right-click the workbook's icon and
    pick View Code. This icon is to the left of the "File" menu this will open
    the VBA editor, in Project Explorer click on your workbook name, if you
    don't see it press CTRL + r to open the Project Explorer, then go to insert,
    module, and paste the code in the window that opens on the right hand side,
    press Alt and Q to close this window and go back to your workbook and press
    alt and F8, this will bring up a box to pick the Macro from, click on the
    Macro name to run it. If you are using excel 2000 or newer you may have to
    change the macro security settings to get the macro to run. To change the
    security settings go to tools, macro, security, security level and set it to
    medium

    If you want them to change names anytime you change A1 in a sheet then try
    this
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Address = "$A$1" Then
    If Target.Value <> "" Then
    On Error Resume Next
    ActiveSheet.Name = Target.Value
    On Error GoTo 0
    End If
    End If
    End Sub

    use the instructions above but put the code in the thisworkbook section


    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "Jeff" <[email protected]> wrote in message
    news:[email protected]...
    > Paul B wrote:
    > > Jeff,
    > > To put in this macro right click on the worksheet tab and view code, in

    the
    > > window that opens paste this code, press Alt and Q to close this window

    and
    > > go back to your workbook. If you are using excel 2000 or newer you may

    have
    > > to change the macro security settings to get the macro to run. To change

    the
    > > security settings go to tools, macro, security, security level and set

    it to
    > > medium
    > >
    > > The code that was posted will work if your sheet is the first sheet in

    the
    > > workbook, if not you may want to try this
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Range)
    > > If Target.Address = "$A$1" Then
    > > If Target.Value <> "" Then
    > > On Error Resume Next
    > > ActiveSheet.Name = Target.Value
    > > On Error GoTo 0
    > > End If
    > > End If
    > >
    > > End Sub
    > >
    > >
    > >

    > Paul, this also works well thank you, can you advise me of a way of
    > using this or another formula to enable me to rename all sheets in a
    > work book ?? do I need to place this formula in all worksheets using the
    > VB editor ??




+ 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