I got this to work as you indicate. Thanks. But, it doesn't solve the problem I'm working on
I have a multi-worksheet workbook. I want Excel to dynamically populate the first column of the first sheet with all the other sheet names in the workbook, one row/cell for each sheet number 2 though n.
I found a way to do this by extracting the sheet name from the filename, then referencing that string in the first sheet. But this approach requires the sheet name to also appear in its own respective sheet - and that's what I'm trying to avoid
''list of sheet names in a workbook - placed on a new worksheet
Sub ShowNames()
Set wkbkToCount = ActiveWorkbook
iRow = 1
With Sheets.Add
'change the preceding line to With Activesheet(no .Add) if you do not want a
new worksheet'
For Each ws In wkbkToCount.Worksheets
.Rows(iRow).Cells(1).Value = ws.Name
iRow = iRow + 1
Next
End With
End Sub
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.