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

#### Alpacas

##### New Member
I would like to hide a row if cells AT4:BM4 are blank.

AlpacaMan

### Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi

Welcome to the forum

Which row do you want to hide?

Hi

Welcome to the forum

Which row do you want to hide?

I'd like to hide the row that they range is on--in this case Row 4.

Thx.

Try
Code:
``````Sub MM1()
If WorksheetFunction.CountA(Range("AT4:BM4")) = 0 Then Rows("4:4").Hidden = True
End Sub``````

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?

AlpacaMan

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``````

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!!

pleasure...

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?

Jennifer

Replies
2
Views
131
Replies
3
Views
162
Replies
16
Views
595
Replies
3
Views
91
Replies
8
Views
178

1,203,619
Messages
6,056,323
Members
444,859
Latest member
nil164

### 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.

### Which adblocker are you using?

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

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