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: 6

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,215,069
Messages
6,122,951
Members
449,095
Latest member
nmaske

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