Show all sheets after the 5 sheets.

KlausW

Active Member
Joined
Sep 9, 2020
Messages
401
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone I use this VBA code to show all sheets in an Excel file. In a sheet.
Work very well. I can't figure out how to get it to show all sheets after the 5th sheet In a sheet.
Anyone who can help?
Any help will be appreciated
Best Regards Klaus W


VBA Code:
Sub ListSheets()

Dim ws As Worksheet
Dim x As Integer

x = 1

'Sheets("Sheet1").Range("A:A").Clear

For Each ws In Worksheets
     Sheets("Sheet1").Cells(x, 2) = ws.Name
     x = x + 1
Next ws

End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this:
VBA Code:
Sub ListSheets()

Dim x As Integer

For x = 6 To Worksheets.Count
     Sheets("Sheet1").Cells(x - 5, 2) = Sheets(x).Name
Next x

End Sub
 
Upvote 0
Solution
Hi everyone I use this VBA code to show all sheets in an Excel file. In a sheet.
Work very well. I can't figure out how to get it to show all sheets after the 5th sheet In a sheet.
Anyone who can help?
Any help will be appreciated
Best Regards Klaus W


VBA Code:
Sub ListSheets()

Dim ws As Worksheet
Dim x As Integer

x = 1

'Sheets("Sheet1").Range("A:A").Clear

For Each ws In Worksheets
     Sheets("Sheet1").Cells(x, 2) = ws.Name
     x = x + 1
Next ws

End Sub
Try this:
VBA Code:
Sub ListSheets()

Dim x As Integer

For x = 6 To Worksheets.Count
     Sheets("Sheet1").Cells(x - 5, 2) = Sheets(x).Name
Next x

End Sub
It works as it should if I want the first name to be in cell b2? How do I go then?
 
Upvote 0
It works as it should if I want the first name to be in cell b2? How do I go then?
VBA Code:
Sub ListSheets()

Dim x As Integer

For x = 6 To Worksheets.Count
     Sheets("Sheet1").Cells(x - 4, 2) = Sheets(x).Name
Next x

End Sub
 
Upvote 0
VBA Code:
Sub ListSheets()

Dim x As Integer

For x = 6 To Worksheets.Count
     Sheets("Sheet1").Cells(x - 4, 2) = Sheets(x).Name
Next x

End Sub
thanks just as it should be have a nice day Best regards from Denmark KW
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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