+ Reply to Thread
Results 1 to 6 of 6

Extracting worksheet names....

  1. #1
    johnT
    Guest

    Extracting worksheet names....

    Hello,

    I use the following formula to display worksheet names in
    a cell:

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

    Is there a way to list the names of all the worksheets in
    the entire workbook on one sheet?

    (thanks)

  2. #2
    Mangesh Yadav via OfficeKB.com
    Guest

    Re: Extracting worksheet names....

    run the following code:

    Sub test()

    Set rng = Worksheets("Sheet1").Range("A1")
    i = 1

    For Each sht In Worksheets
    rng(i, 1) = sht.Name
    i = i + 1
    Next

    End Sub


    place it in any module to run it.

    - Mangesh

    --
    Message posted via http://www.officekb.com

  3. #3
    johnT
    Guest

    Re: Extracting worksheet names....

    thanks, but is there a way to automatically update the
    list if i was to insert another worksheet??
    >-----Original Message-----
    >run the following code:
    >
    >Sub test()
    >
    > Set rng = Worksheets("Sheet1").Range("A1")
    > i = 1
    >
    > For Each sht In Worksheets
    > rng(i, 1) = sht.Name
    > i = i + 1
    > Next
    >
    >End Sub
    >
    >
    >place it in any module to run it.
    >
    >- Mangesh
    >
    >--
    >Message posted via http://www.officekb.com
    >.
    >


  4. #4
    LanceB
    Guest

    Re: Extracting worksheet names....

    You could place Mangesh's example in "ThisWorkbook" code page

    Private Sub Workbook_NewSheet(ByVal Sh As Object)
    Set rng = Worksheets("Sheet1").Range("A1")
    i = 1

    For Each sht In Worksheets
    rng(i, 1) = sht.Name
    i = i + 1
    Next
    End Sub


    "johnT" wrote:

    > thanks, but is there a way to automatically update the
    > list if i was to insert another worksheet??
    > >-----Original Message-----
    > >run the following code:
    > >
    > >Sub test()
    > >
    > > Set rng = Worksheets("Sheet1").Range("A1")
    > > i = 1
    > >
    > > For Each sht In Worksheets
    > > rng(i, 1) = sht.Name
    > > i = i + 1
    > > Next
    > >
    > >End Sub
    > >
    > >
    > >place it in any module to run it.
    > >
    > >- Mangesh
    > >
    > >--
    > >Message posted via http://www.officekb.com
    > >.
    > >

    >


  5. #5
    johnT
    Guest

    Re: Extracting worksheet names....

    i can't seem to get this working???
    >-----Original Message-----
    >You could place Mangesh's example in "ThisWorkbook" code

    page
    >
    >Private Sub Workbook_NewSheet(ByVal Sh As Object)
    > Set rng = Worksheets("Sheet1").Range("A1")
    > i = 1
    >
    > For Each sht In Worksheets
    > rng(i, 1) = sht.Name
    > i = i + 1
    > Next
    >End Sub
    >
    >
    >"johnT" wrote:
    >
    >> thanks, but is there a way to automatically update the
    >> list if i was to insert another worksheet??
    >> >-----Original Message-----
    >> >run the following code:
    >> >
    >> >Sub test()
    >> >
    >> > Set rng = Worksheets("Sheet1").Range("A1")
    >> > i = 1
    >> >
    >> > For Each sht In Worksheets
    >> > rng(i, 1) = sht.Name
    >> > i = i + 1
    >> > Next
    >> >
    >> >End Sub
    >> >
    >> >
    >> >place it in any module to run it.
    >> >
    >> >- Mangesh
    >> >
    >> >--
    >> >Message posted via http://www.officekb.com
    >> >.
    >> >

    >>

    >.
    >


  6. #6
    LanceB
    Guest

    Re: Extracting worksheet names....

    In the visual basic editor right click on the "ThisWorbook" icon and select
    view code. Paste the example there. It won't work in a regular code module

    "johnT" wrote:

    > i can't seem to get this working???
    > >-----Original Message-----
    > >You could place Mangesh's example in "ThisWorkbook" code

    > page
    > >
    > >Private Sub Workbook_NewSheet(ByVal Sh As Object)
    > > Set rng = Worksheets("Sheet1").Range("A1")
    > > i = 1
    > >
    > > For Each sht In Worksheets
    > > rng(i, 1) = sht.Name
    > > i = i + 1
    > > Next
    > >End Sub
    > >
    > >
    > >"johnT" wrote:
    > >
    > >> thanks, but is there a way to automatically update the
    > >> list if i was to insert another worksheet??
    > >> >-----Original Message-----
    > >> >run the following code:
    > >> >
    > >> >Sub test()
    > >> >
    > >> > Set rng = Worksheets("Sheet1").Range("A1")
    > >> > i = 1
    > >> >
    > >> > For Each sht In Worksheets
    > >> > rng(i, 1) = sht.Name
    > >> > i = i + 1
    > >> > Next
    > >> >
    > >> >End Sub
    > >> >
    > >> >
    > >> >place it in any module to run it.
    > >> >
    > >> >- Mangesh
    > >> >
    > >> >--
    > >> >Message posted via http://www.officekb.com
    > >> >.
    > >> >
    > >>

    > >.
    > >

    >


+ 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