Extracting worksheet names....

  • Thread starter Thread starter johnT
  • Start date Start date
J

johnT

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)
 
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
 
thanks, but is there a way to automatically update the
list if i was to insert another worksheet??
 
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 said:
thanks, but is there a way to automatically update the
list if i was to insert another worksheet??
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top