Hiding a row across multiple sheets

frankday

Board Regular
Joined
Apr 13, 2012
Messages
103
I am trying to hide row 129 across these sheets. It works great but when done all the sheets are high lighted. I want it to return to sheet "Chart of Accounts" only. It doesn't mater what cell. Any help would be great. Thanks

Sub Line129callapes()


Sheets(Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")).Select
Rows(129).EntireRow.Hidden = True
Range("A144") = 0
Range("B144").Select

End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
That worked great. But I was wrong. The VB is only hiding row 129 on sheet "January" How do I get this to work across all windows?
 
Upvote 0
Something like:

Code:
dim myarr as variant
myarr = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
for i = 0 to 11
sheets(myarr(i)).rows(129).entirerow.hidden = true
next
 
Upvote 0
I may have put it in the wrong spot. I get a bug in line "Sheets(myarr(i)).Rows(129).EntireRow.Hidden = True"

Sub Line129cal()


Dim myarr As Variant
myarr = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
For i = 0 To 11
Sheets(myarr(i)).Rows(129).EntireRow.Hidden = True
Next
Sheets("Chart of Accounts").Select
Range("F144") = 1
Range("B144").Select


End Sub
 
Upvote 0
Try this:
Code:
Sub My_Sheets()
'Modified  9/30/2018  8:13:10 PM  EDT
Application.ScreenUpdating = False
Dim Dell As Variant
Dell = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
ans = UBound(Dell)
For i = 0 To ans
    With Sheets(Dell(i))
        .Rows(129).Hidden = True
        .Range("A144") = 0
        Application.Goto .Range("B144")
    End With
Next
Application.Goto Sheets("Chart of Accounts").Range("A1")
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I test all my scripts.
I suspect you do not have your sheets properly named.
Are you using a PC or a MAC

What version of Excel are you using.

Are you sure each sheet in the array is spelled exactly correct?
 
Last edited:
Upvote 0
Thank you, I tried it on a test workbook and it worked great. Now I have one more obstetrical if possible. I am also using a macro to hide rows on a sheet and then unhide them when ran again. The problem is when I hide a row using the "my sheets" code that was posted yesterday by board regular and then I use the code that hides multiple sheets, when I unhide using the multiple sheets code it also unhides the row that was hidden by "my sheets" code. Sorry, I can't figure out how to attache a file so I put the code below.

Thanks

Sub My_Sheets()'Modified 9/30/2018 8:13:10 PM EDT
Application.ScreenUpdating = False
Dim Dell As Variant
Dell = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
ans = UBound(Dell)
For i = 0 To ans
With Sheets(Dell(i))
.Rows(7).Hidden = True
.Range("D7") = 0
Application.Goto .Range("A7")
End With
Next
Application.Goto Sheets("Chart of Accounts").Range("A7")
Application.ScreenUpdating = True
End Sub

Multi Row Hide Code

Sub Toggle_January()
If Rows("4:15").EntireRow.Hidden = True Then
Call Expand_January
Else
Call Callapes_January
End If
End Sub


Sub Callapes_January()
Rows("4:15").EntireRow.Hidden = True
Range("h3") = 1
Range("H3").Select
End Sub


Sub Expand_January()
Rows("4:15").EntireRow.Hidden = False
Range("H3") = 0
Range("H3").Select
End Sub
 
Upvote 0
My original code hid row 129 like you originally asked for.
But you changed the code to hide row 7

Now you have another code that says unhide rows(4:17) which includes row(7)
So your telling different codes to do different things.
I have no solution. You will need to sort out what you want.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
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