Hiding rows on condition that all (most) are blank

dudewheresmyvba

New Member
Joined
Jul 6, 2017
Messages
29
After not finding examples that apply to my situation, I've come here for VBA help.

I am wanting to hide rows with a macro when B:I are blank. There are formulas in them but the ones that I want hidden have errors in them that I have set to "". So its is a normal table with headers on the top and in column A, A2:I33 is the range I want to hide rows individually, if they have no value in B:I.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Untested

Code:
Sub HROCTAMAB()
Dim lRow As Long
Dim R2H As Long

lRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, _
           SearchDirection:=xlPrevious, LookIn:=xlValues).Row
  
For R2H = lRow To 2 Step -1
        If WorksheetFunction.CountA(Range(Cells(R2H, "B"), Cells(R2H, "I"))) = 0 Then
            Rows(R2H).Hidden = True
        End If
  Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,104
Messages
6,128,856
Members
449,472
Latest member
ebc9

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