Using For loop counter in Sheet name

PioSwgr

New Member
Joined
Dec 22, 2023
Messages
8
Office Version
  1. 365
New here. I'm attempting to condense the commented out code with the nested for loops above. Can't get vba to recognize the "i" counter in worksheet sheet name. For example, I have it as "Section i" and on the first loop I want it to read "Section 2" in order to make macro hide the sheet labeled "Sheet 2". Any help or direction would be great, thanks
 

Attachments

  • Hide Sheets .png
    Hide Sheets .png
    69.6 KB · Views: 8

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Welcome to the Board!

Anything between the double-quotes is treated as literal text. So variables need to be outside of the double-quotes, i.e.
VBA Code:
Worksheets("Section " & i)
 
Upvote 1
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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