Putting worksheet name into cell on that sheet
VBA Telemetry pings you when your VBA projects fail
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: Putting worksheet name into cell on that sheet

  1. #1
    Board Regular shades's Avatar
    Join Date
    Mar 2002
    Location
    Near the Land of Oz
    Posts
    1,550
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I remember seeing a response recently about a formula that takes the worksheet "name" and then inserts that into a cell on that worksheet.


    [Nuts! I tried to search, but the search function isn't working right now, and I have searched 25+ pages and can't find what I need.]
    - old, slow, and confused
    ... but at least I'm inconsistent -

    (retired Excel 2003 user, 3.28.2008)

  2. #2
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-12 12:49, shades wrote:
    I remember seeing a response recently about a formula that takes the worksheet "name" and then inserts that into a cell on that worksheet.


    [Nuts! I tried to search, but the search function isn't working right now, and I have searched 25+ pages and can't find what I need.]
    Try =MID(CELL("filename"),FIND("]",CELL("filename"),1)+1,255)


    Kind Regards,
    Ivan F Moala From the City of Sails

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    http://www.mrexcel.com/board/viewtop...c=3816&forum=2

    Methinks this hast what thou needest.
    "Interfere? Of course we should interfere! Always do what you're best at, that's what I say!" -- The Doctor, Nightmare of Eden

  4. #4
    Board Regular
    Join Date
    Apr 2002
    Location
    Oregon
    Posts
    77
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    try this


    Sub sheet_name()
    Range("a1") = ActiveSheet.Name
    End Sub

  5. #5
    Board Regular shades's Avatar
    Join Date
    Mar 2002
    Location
    Near the Land of Oz
    Posts
    1,550
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks, Ivan, that's the approach I'm looking for.

    However, that only works once in the entire workbook.

    I have seven tabs: Q1-01, Q2-01, Q3-01 Q4-01, Q1-Q2, Q1-Q3, Q1-Q4.

    Once I pasted in your formula into cell Q1-01!J3, it did what I wanted ("Q1-01" was in the cell). But when I pasted the formula into another sheet (Q2-01!J3), it took the name of that one ("Q2-01"), and then when I went back to worksheet Q1-01, that cell (Q1-01!J3) had changed to Q2-01.
    - old, slow, and confused
    ... but at least I'm inconsistent -

    (retired Excel 2003 user, 3.28.2008)

  6. #6
    MrExcel MVP Jay Petrulis's Avatar
    Join Date
    Mar 2002
    Location
    Chicago, IL USA
    Posts
    2,040
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    If you want a worksheet function which is easier to use than the =MID(CELL(....

    try the following UDF:

    Public Function NameSheet()
    NameSheet = Application.Caller.Parent.Name
    End Function

    Called as =NAMESHEET()

  7. #7
    Board Regular
    Join Date
    Mar 2002
    Posts
    363
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    if you use Ivan's approach you should add a cell reference (a1) after "filename" to the formula to assure you get name of the active sheet without the need to recalc:

    =MID(CELL("filename",a1),FIND("]",CELL("filename",a1),1)+1,255)



    It's never too late to learn something new.

    Ricky

  8. #8
    Board Regular shades's Avatar
    Join Date
    Mar 2002
    Location
    Near the Land of Oz
    Posts
    1,550
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks, everyone!

    Ricky, that little extra made the difference. And all of you made my day!!!
    - old, slow, and confused
    ... but at least I'm inconsistent -

    (retired Excel 2003 user, 3.28.2008)

  9. #9
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    On 2002-04-12 13:14, Ricky Morris wrote:
    if you use Ivan's approach you should add a cell reference (a1) after "filename" to the formula to assure you get name of the active sheet without the need to recalc:

    =MID(CELL("filename",a1),FIND("]",CELL("filename",a1),1)+1,255)



    Good one Ricky...I'd forgotten about that for
    Multisheet use.

    Kind Regards,
    Ivan F Moala From the City of Sails

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
  •  

 

 
DMCA.com