Thread: Worksheet Name
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Todd Huttenstine[_2_] Todd Huttenstine[_2_] is offline
external usenet poster
 
Posts: 237
Default Worksheet Name

Sorry for this but I have to make a modification to this
code. Actually I would like for it to start listing the
names of the work sheets in Cell A3 instead of A1. And
also I need for it to start listing the names of the
worksheets on sheet3 instead of the first sheet in the
workbook.

Thank you.


-----Original Message-----
Todd,

Sorry again, the touchpad is playing up tonight.

Here's the code.

Sub SheetNames()
Dim sh As Worksheet
Dim i As Long

Columns(1).ClearContents
i = 1
For Each sh In ThisWorkbook.Worksheets
ActiveSheet.Cells(i, "A").Value = sh.Name
i = i + 1
Next sh

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine"

wrote in message
...
on sheet1 in cell A1 I want for the name of sheet1 to
appear in this cell. In cell A2 I want for the name of
sheet2 to appear. In cell A3 I want for the name of
sheet3 to appear and so on until sheet50.....

This means A1:A50 will be a list of sheet names. Also
lets say if there are only 25 sheets instead of 50. If
this is the case I need for the code to leave the
remaining 25 cells in columnA blank and not put in a

sheet
name because there are no sheets. So I need the code to
list the names of all the sheets but if there are no
sheets to leave the cell blank.

Thank you

Todd Huttenstine



.