can I get the sheet name and place it in a cell for all sheets in the
workbook without referencing the activesheet method? all I want is to place
the sheetname in a cell.
Sub GetSheetNames()
For Each w In Worksheets
w.[A1].Value = w.Name
Next w
End Sub
--
Spam buster:
To send me e-mail, remove the "hello..." from my e-mail address (I
hate spambots).
I couldn't quite tell exactly what you were trying to describe. The first
of the following two Sub Procedures puts a list of all Sheet names
(worksheets and other sheets) in Column A of the first worksheet starting
at A1. The second one puts the name of each Worksheet into Cell A1 of that
worksheet.
Sub test3()
For Each sh In Sheets
i = i + 1
Worksheets(1).Range("A" & i).Value = sh.Name
Next
End Sub
Sub test4()
For Each sh In Worksheets
sh.[a1].Value = sh.Name
Next
End Sub
Good luck,
Alan Beban be...@pacbell.net
cas...@aol.com (Casbhu) wrote in article
<19970916172...@ladder02.news.aol.com>...
Casbhu,
Yes you can. The following sub will do that for you.
Sub Get_Names()
For i = 1 To Worksheets.Count
ActiveCell = Sheets(1).Name
ActiveCell.Offset(1, 0).Select
Next
End Sub
Casbhu <cas...@aol.com> wrote in article
In Excel 95 and 97 you can use the following worksheet formula to get
the sheet name. No macro code is required:
=MID(CELL("FileName"),FIND("]",(CELL("FileName")))+1,999)
If you want the full workbook reference, including path, just use:
=CELL("FileName")
Note that the workbook must be saved for the above to work.
Hope this helps,
John Green
Sydney
Australia
Microsoft MVP - Excel
>
>If you want the full workbook reference, including path, just use:
>
>=CELL("FileName")
>
G'day John
I recommend
=CELL("FileName",A1)
which is less likely to fail if a different sheet is active when you
recalculate
Bill Manville
Oxford, England
Microsoft Excel - MVP
Good point,