+ Reply to Thread
Results 1 to 4 of 4

How do I reference a worksheet name in a cell, or vice versa?

  1. #1
    ilmeaz
    Guest

    How do I reference a worksheet name in a cell, or vice versa?

    If I want to label worksheet by date for example, and I want the date to show
    in cell A1, how can I either have cell A1 produce the worksheet tab name, or
    reflect that name within the cell?

  2. #2
    Registered User
    Join Date
    04-21-2005
    Posts
    46
    Just create a user-defined function as follows:

    Open up VBA and insert a new module. (insert menu, "module"). In the box that comes up, insert this code:

    Function sheetname() As Variant
    sheetname = ActiveSheet.Name
    End Function

    Compile the script and close out VBA. Type =sheetname() into cell A1 and you're good to go.

  3. #3
    JE McGimpsey
    Guest

    Re: How do I reference a worksheet name in a cell, or vice versa?

    take a look at


    http://mcgimpsey.com/excel/formulae/cell_function.html


    In article <[email protected]>,
    ilmeaz <[email protected]> wrote:

    > If I want to label worksheet by date for example, and I want the date to show
    > in cell A1, how can I either have cell A1 produce the worksheet tab name, or
    > reflect that name within the cell?


  4. #4
    Gord Dibben
    Guest

    Re: How do I reference a worksheet name in a cell, or vice versa?

    To have the worksheet tab name follow the cell value.......

    From Bob Phillips..........

    Private Sub Worksheet_Change(ByVal Target As Range)
    'autoname the worksheet Tab from value in A5
    If Target.Cells.Count > 1 Then Exit Sub
    If Intersect(Target, Me.Range("A5")) Is Nothing Then Exit Sub
    On Error GoTo CleanUp
    Application.EnableEvents = False
    With Target
    If .Value <> "" Then
    Me.Name = .Value
    End If
    End With
    CleanUp:
    Application.EnableEvents = True
    End Sub

    Alternative on a button or shortcut key.

    Sub SheetName()
    ActiveSheet.Name = Range("A5")
    End Sub

    To have the cell value follow the worksheet tab name see Bob's site....

    http://www.xldynamic.com/source/xld.xlFAQ0002.html


    Gord Dibben Excel MVP

    On Mon, 2 May 2005 11:00:15 -0700, ilmeaz <[email protected]>
    wrote:

    >If I want to label worksheet by date for example, and I want the date to show
    >in cell A1, how can I either have cell A1 produce the worksheet tab name, or
    >reflect that name within the cell?



+ 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