Hi,
I have a Worksheet with +25 sheets in it.
Some sheets have 4,000 rows, most where the cell values in the enitre row ar zero.
I'd like to have one button that will hide these rows and another to unhide them.
Many thanks
Hi,
I have a Worksheet with +25 sheets in it.
Some sheets have 4,000 rows, most where the cell values in the enitre row ar zero.
I'd like to have one button that will hide these rows and another to unhide them.
Many thanks
e/ Just realized you mentioned multiple sheets also. I will edit for all sheets.![]()
Sub test() Dim l As Long Dim lRow As Long lRow = Range("A" & Rows.Count).End(xlUp).Row For l = 1 To lRow If Application.WorksheetFunction.Sum(Rows(l)) = 0 Then Rows(l).Hidden = True End If Next l End Sub
Thanks,
Solus
Please remember the following:
1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.Highlight the code in your post and press the # button in the toolbar.2. Show appreciation to those who have helped you by clickingbelow their posts.
3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.
"Slow is smooth, smooth is fast."
![]()
Sub test() Dim ws As Worksheet Dim l As Long Dim lRow As Long For Each ws In Worksheets lRow = ws.Range("A" & Rows.Count).End(xlUp).Row For l = 1 To lRow If Application.WorksheetFunction.Sum(ws.Rows(l)) = 0 Then ws.Rows(l).Hidden = True End If Next l Next ws End Sub
Thank you for being so quick!
Do you have one for the Unhide button?
Much appreciated
Unhide all? or only unhide rows that total to 0?
Ahhh I see ... both would have the same result
I could quite easily record a macro that will unhide all rows
Sometimes blinded by science
Thank you for all your help!
Glad to help.
You can also try this:![]()
Sub test() Dim ws As Worksheet For Each ws In Worksheets ws.UsedRange.EntireRow.Hidden = False Next ws End Sub
Thank you, I will do!
Hi, is there a way to update the code or even my sheets so that lines where there is noting ae not hidden, else presentation is affected. Let me explain .. say I have
Assets
Liabilities
Capital
Expenses
I don't want it to look like ..
Assets
Liabilities
Capital
Expenses
Hope I make sense
Ta
I'm not sure I understand, you don't want the entire row hidden if what?
If there is nothing in that row
Sorry I should have been more clear. I believe there are certain rows that you do not want hidden:
Which are the rows that you never want hidden because they effect presentation if they are hidden?Hi, is there a way to update the code or even my sheets so that lines where there is noting ae not hidden, else presentation is affected.
I have rows with multiple columns that contain formulae, and in some of these rows all the values in the columns are zero - I want these hidden
Some rows have absolutley nothing in them, they are left blank - I do not want these hidden
Ta
Ah. I understand. What column to the 0's start in?
Column D
Could use something like ...(I'm a novice so I'm unsure)
If Application.CountA(ActiveCell.EntireRow)=0 Then
End IF
Else Application.WorksheetFunction.Sum(Rows(l)) = 0 Then
Rows(l).Hidden = True
End If
Column D
Could use something like ...(I'm a novice so I'm unsure)
If Application.CountA(ActiveCell.EntireRow)=0 Then
End IF
Else Application.WorksheetFunction.Sum(Rows(l)) = 0 Then
Rows(l).Hidden = True
End If
try![]()
Sub test() Dim ws As Worksheet Dim l As Long Dim lRow As Long For Each ws In Worksheets lRow = ws.Range("A" & Rows.Count).End(xlUp).Row For l = 1 To lRow If ws.Range("D" & l).Value <> "" Then If Application.WorksheetFunction.Sum(ws.Rows(l)) = 0 Then ws.Rows(l).Hidden = True End If End If Next l Next ws End Sub
Awesome! That's it!
Thank you very much![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks