Hide row if cell is blank

Littlemalky

Board Regular
Joined
Jan 14, 2011
Messages
223
I have a range("D35:D44"), and if any of those cells do not contain a value in them, then I need the entire row to be hidden, so that only the cells in that range are shown. All the code I've found is for a specific value it seems, rather than a blank cell.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Actually, I did an IFERROR to input blank cells in the ranges that don't have a value which is perfect for me because i needed to exclude all the partnumbers that return an actual value because that means they have been used already.

Now, I have to actually do this with columns D:H, so I just tried to put a ":H" whereever there was a D with that code, but it didn't seem to work. Do you have a solution for doing this in multiple columns with the last code i just posted so I don't have to repeat the same code for each column 5 times?
 
Upvote 0
Try

Code:
Private Sub DelRows2()
    Dim LR As Long, i As Long
    LR = Cells(Rows.Count, "D").End(xlUp).Row
    For i = LR To 2 Step -1
        If WorksheetFunction.CountA(Range("D" & i).Resize(, 5)) < 5 Then Range("D" & i).Resize(, 5).Delete shift:=xlShiftUp
    Next i
End Sub
 
Upvote 0
It won't resize any columns. Try

Code:
Sub DelRows2()
    Dim LR As Long, i As Long, j As Long
    LR = Cells(Rows.Count, "D").End(xlUp).Row
    For i = LR To 2 Step -1
        For j = 4 To 8
            If Cells(i, j).Value = "" Then
                Range("D" & i).Resize(, 5).Delete shift:=xlShiftUp
                Exit For
            End If
        Next j
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

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