How to hide a row if a range of cells are blank

Alpacas

New Member
Joined
Mar 20, 2013
Messages
4
I would like to hide a row if cells AT4:BM4 are blank.

Thanks for any help you can give.

AlpacaMan
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try
Code:
Sub MM1()
If WorksheetFunction.CountA(Range("AT4:BM4")) = 0 Then Rows("4:4").Hidden = True
End Sub
 
Upvote 0
Try
Code:
Sub MM1()
If WorksheetFunction.CountA(Range("AT4:BM4")) = 0 Then Rows("4:4").Hidden = True
End Sub

Thx for your time and expertise.

There are multiple rows in the sheet that need to be hidden based upon a range of AT#:BM# where # are the number of rows in the sheet. Could you vary the macro code to include them?

Again, I appreciate your help.

AlpacaMan
 
Upvote 0
Assuming that you have data all the way down column "A" try
Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row 'change col reference to suit
    For r = lr To 2 Step -1
        If WorksheetFunction.CountA(Range("AT" & r & ":BM" & r)) = 0 Then Rows(r).Hidden = True
    Next r
End Sub
 
Upvote 0
Assuming that you have data all the way down column "A" try
Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row 'change col reference to suit
    For r = lr To 2 Step -1
        If WorksheetFunction.CountA(Range("AT" & r & ":BM" & r)) = 0 Then Rows(r).Hidden = True
    Next r
End Sub

Thx very much!!
 
Upvote 0
Hi Michael,

How would I change this code so that I could use to hide the row

if coulmns D to (last column) which will vary workbook to workbook?

Thanks for your help!

Jennifer
 
Upvote 0

Forum statistics

Threads
1,215,835
Messages
6,127,167
Members
449,368
Latest member
JayHo

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