Excel VBA to unhide specific rows across multiple sheets

Stuepef

Board Regular
Joined
Oct 23, 2017
Messages
128
Office Version
  1. 2021
Platform
  1. Windows
I am looking to construct a VBA that unhides specific rows across different sheets in a workbook. I can write separate VBA for each sheet/row combination, but was wondering if I can put them all together instead?

3 sheets need the same rows unhidden that I already have code for:
Code:
Sub Test()
Application.ScreenUpdating = False
      Dim wsMySheet As Worksheet
      For Each wsMySheet In Sheets(Array(Sheet6.Name, Sheet7.Name, Sheet8.Name))
      With wsMySheet
         .Rows("26:75").EntireRow.Hidden = False
      End With
      Next wsMySheet
   Application.ScreenUpdating = True
End Sub

But I am looking to incorporate these sheets/rows into the code above if possible:
Sheet3 - Rows 11:239
Sheet5 - Rows 23:146
Sheet4 - Rows 11:60
Sheet10 - Rows 28:77

Thank you!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
How about
Code:
Sub Stuepef()
Application.ScreenUpdating = False
   Dim Ary As Variant
   Dim i As Long
   
   Ary = Array(Sheet6, "26:75", Sheet7, "26:75", Sheet8, "26:75", Sheet3, "11:239")
   For i = 0 To UBound(Ary) Step 2
      Ary(i).Rows(Ary(i + 1)).Hidden = False
   Next i
End Sub
Just add the rest of the sheet codenames & rows to the array
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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