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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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