worksheet name in cell
worksheet name in cell
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: worksheet name in cell

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    is there a way to insert the worksheet name into a cell
    EG:
    sheet 1 name is "John"
    sheet 2 name is "brian"

    on another worksheet "summary" i want to insert these two worksheet names in cells a1 and a2.

    regards

  2. #2
    New Member
    Join Date
    Apr 2002
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I don't know if this is the easiest way, but this formula seems to work:

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

    (Change the 20 at the end of the formula to the maximum length you expect the sheet name might be.)

  3. #3
    New Member
    Join Date
    Mar 2002
    Location
    Canberra AU
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    =RIGHT(CELL("Filename"),LEN(CELL("filename"))-SEARCH("]",CELL("filename")))
    and another

    Dave

  4. #4
    New Member
    Join Date
    Apr 2002
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    these work, but what i would really like to do is be able to drag down so it finds the next worksheet name, and the next, etc.....
    i have 26 sheets in total

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Brisbane, Down Under
    Posts
    542
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-09 04:42, imillar wrote:
    these work, but what i would really like to do is be able to drag down so it finds the next worksheet name, and the next, etc.....
    i have 26 sheets in total
    Some other answers here which may assist you.
    http://www.mrexcel.com/board/viewtop...c=3816&forum=2

  6. #6
    New Member
    Join Date
    Aug 2012
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: worksheet name in cell

    I would like to offer a better, more versatile, version of the formula above: MID(CELL("filename"),FIND("]",CELL("filename"))+1,20)

    If you copy this formula in 10 different sheets, all 10 formulas will return the result of the ACTIVE sheet. Instead:

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

    This formula will return the result of the sheet where the formula exists.


    Excel Magic Trick 756: Create Sequential Dates Across Sheets & Extract Sheet Name To Cell - YouTube

  7. #7
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    9,057
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: worksheet name in cell

    With a macro?

    Code:
    Sub Summary()   Dim ws As Worksheet, n As Integer
        Application.ScreenUpdating = False
        n = 1
        For Each ws In ActiveWorkbook.Worksheets
            If ws.Name <> "Summary" Then
                Sheets("Summary").Range("a" & n) = ws.Name
                n = n + 1
            End If
        Next
        Application.ScreenUpdating = True
    End Sub
    Last edited by MARK858; Nov 4th, 2012 at 02:59 AM.
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, Excel jeanie, RoryA addin (Win & Mac) or Borders-Copy-Paste

  8. #8
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    9,057
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: worksheet name in cell

    Sorry that came out badly on on the edit.

    Code:
    Sub Summary()
       Dim ws As Worksheet, n As Integer
        Application.ScreenUpdating = False
        n = 1
        For Each ws In ActiveWorkbook.Worksheets
            If ws.Name <> "Summary" Then
                Sheets("Summary").Range("a" & n) = ws.Name
                n = n + 1
            End If
        Next
        Application.ScreenUpdating = True
    End Sub
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, Excel jeanie, RoryA addin (Win & Mac) or Borders-Copy-Paste

  9. #9
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    9,057
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: worksheet name in cell

    Suddenly realised this thread is 10 years old???
    Nice to know that people still like offering solutions but....
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, Excel jeanie, RoryA addin (Win & Mac) or Borders-Copy-Paste

  10. #10
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    81,752
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default Re: worksheet name in cell

      
    Quote Originally Posted by imillar View Post
    these work, but what i would really like to do is be able to drag down so it finds the next worksheet name, and the next, etc.....
    i have 26 sheets in total
    Quote Originally Posted by econocrat View Post
    I would like to offer a better, more versatile, version of the formula above: MID(CELL("filename"),FIND("]",CELL("filename"))+1,20)

    If you copy this formula in 10 different sheets, all 10 formulas will return the result of the ACTIVE sheet. Instead:

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

    This formula will return the result of the sheet where the formula exists.


    Excel Magic Trick 756: Create Sequential Dates Across Sheets & Extract Sheet Name To Cell - YouTube
    The length of 20 is retrictive. I think a sheet name can have 31 chars, the max length allowed. The following does not require such a specification:

    =REPLACE(CELL("filename",A1),1,FIND("]",CELL("filename",A1)),"")

    By the way, the OP wants to list all sheets...

    Define Sheets by means of Insert | Name | Define or Formulas | Name Manager as referring to:

    =REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")

    Invoke now in A1 on Summary...

    Either:

    =IF(ROWS($A$1:A1)<=COUNTA(Sheets),INDEX(Sheets,ROWS($A$1:A1)),"")

    Or:

    =IFERROR(INDEX(Sheets,ROWS($A$1:A1)),"")
    Assuming too much and qualifying too much are two faces of the same problem.

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