VBA to List Sheet Names

ANE0709

Board Regular
Joined
Feb 2, 2022
Messages
65
Office Version
  1. 365
Platform
  1. Windows
I am trying to list the sheet names within the workbook using VBA. I found the following code online for which i modified for my particular project. problem is i need to take it one step further but not sure how exactly to modify it. As-is this code is currently listing all tabs. i do not want to list the first 7 tabs. How can i modify the code to start listing the sheet names starting with tab 8?

Sub ListAllSheets()

Dim ws As Worksheet
Dim Counter As Integer

Counter = c

For Each ws In ActiveWorkbook.Worksheets
Sheets("Metrics").Select
Range("B3").Select
ActiveCell.Offset(Counter, 0).Value = ws.Name
Counter = Counter + 1

Next ws

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
How about
VBA Code:
Sub ListAllSheets()
   Dim i As Long
   
   For i = 8 To Worksheets.Count
      Sheets("Metrics").Range("B3").Offset(i - 8).Value = Worksheets(i).Name
   Next i
End Sub
 
Upvote 0
How about this?

VBA Code:
Sub ListAllSheets()
  
With CreateObject("Scripting.Dictionary")
    For i = 8 To ActiveWorkbook.Worksheets.Count
        .Add Sheets(i).Name, True
    Next i
    ActiveCell.Resize(.Count).Value = Application.Transpose(.Keys)
End With

End Sub
 
Upvote 0
One more

VBA Code:
Sub jec()
 Dim c00, i As Long
 For i = 8 To Sheets.Count
   c00 = c00 & "|" & Sheets(i).Name
 Next
 Range("B3").Resize(i - 8) = Application.Transpose(Split(Mid(c00, 2), "|"))
End Sub
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top