Assemble list of sheet names

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
574
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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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

Forum statistics

Threads
1,223,060
Messages
6,169,861
Members
452,286
Latest member
noclue2000

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