Does anyone have a code that would put the names of all worksheets to the right of sheet3, in the cells of row 1 after the last column in the last worksheet. Thanks!
Sub GetSheetNames()
Dim lColumn As Long
Dim ws As Worksheet
For Each ws In Sheets
lColumn = Sheets(Sheets.Count).Cells(1, Columns.Count).End(xlToLeft).Column
Sheets(Sheets.Count).Cells(1, lColumn + 1) = ws.Name
Next ws
End Sub
That works great, but it pulls all the worksheet names. Is there a way to only pull a certain range of worksheets. For example if you had 10 worksheets, you would pull the names from worksheets 4-8?
Sub GetSheetNames()
Dim lColumn As Long
Dim x As Long
For x = 4 To 8
lColumn = Sheets(Sheets.Count).Cells(1, Columns.Count).End(xlToLeft).Column
Sheets(Sheets.Count).Cells(1, lColumn + 1) = Sheets(x).Name
Next x
End Sub
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.