Assemble list of sheet names

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
569
Office Version
  1. 365
Platform
  1. Windows
I have a single workbook with several worksheets. I would like to generate a list of names and have them added to my sheet named "Data", in column L which has a header in L1 of "Sheets Names". Each sheet has the tab name listed in cell CA1. I have the code listed below to generate the list of tabs and place them in the Data sheet in column L starting with L2. The code below does not work at the moment, it does not generate the list and deletes the header in L1. I also have the issue that some tabs will be visible and some wont. I only want the visible tabs to have their names added to the list.

Thanks for the help.

Robert

Code:
Sub SHEET_NAMES()


Dim s As Worksheet
Dim tabname As Variant


Sheets("Data").Visible = True
Sheets("Data").Range("L2").Select


For Each s In Worksheets


tabname = Range("CA1").Value


Sheets("Data").Range("L2").Select
Range(Selection, Cells(Rows.Count, Selection.Column).End(xlUp)).Select
Selection = tabname


Next s




End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try:
Code:
Sub SHEET_NAMES()
    Application.ScreenUpdating = False
    Dim i As Long
    For i = 1 To Sheets.Count
        If Sheets(i).Visible = True Then
            Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Sheets(i).Name
        End If
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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