Function ListSheets() As String
For Each sht In ActiveWorkbook.Sheets
ListSheets = ListSheets & "," & sht.Name
Next
End Function
Sub aa()
MsgBox Mid(ListSheets, 2)
End Sub
Run the sub aa to get a comma delimited string containing the names of the
sheets. If you want to include worksheets only, replace ActiveWorkbook.Sheets
by ActiveWorkbook.Worksheets.
Sub qwerty4()
'Workbook must have reference to Microsoft Scripting Runtime
Dim dic As Dictionary, rng As Range
Set dic = New Dictionary
Set rng = Range("A1:A" & ActiveWorkbook.Sheets.Count)
For Each sh In ActiveWorkbook.Sheets
dic.Add CStr(sh.Name), sh.Name
Next
rng.Value = Application.Transpose(dic.Items)
End Sub
Sub qwerty5()
Dim arr, rng As Range
Dim i As Integer, n As Integer, m As Object
Set m = ActiveWorkbook.Sheets
n = m.Count
Set rng = Range("A1:A" & n)
ReDim arr(1 To n, 1 To 1)
i = 1
For Each sh In m
arr(i, 1) = sh.Name
i = i + 1
Next
rng.Value = arr
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.