Hide Row if cell doesn't have a value

GuyGadois

Active Member
Joined
Jan 12, 2009
Messages
344
Office Version
  1. 2019
Platform
  1. Windows
I have the following code which works if the cell doesn't have any value but doesn't work if the cell has a formula that produces no value. What I am looking for is a way to hide the row if the cell is empty or has a formula that produces no value. Is this possible?

Guy

Code:
Sub HideRows()
    Application.ScreenUpdating = False
    Dim s As String
    For i = 5 To Range("B4:B206").Count
        s = i & ":" & i
        If IsEmpty(Cells(i, 3).Value) Then
            Rows(s).Select
            Selection.EntireRow.Hidden = True
       End If
    Next
    Application.ScreenUpdating = True
End Sub
 

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 HideRows()
    Application.ScreenUpdating = False
    Dim i As Long
    For i = 5 To Range("B4:B206").Count
        If Len(Cells(i, 3)) = 0 Then
            Rows(i).Hidden = True
       End If
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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