VBA to hide rows

bakerman

Board Regular
Joined
Sep 9, 2005
Messages
188
I have been trying to find an old post that answers my question but i've had no luck.
What I want to do is hide or unhide a row based on the value in colloum D of the row that is being hidden or unhidden. I need this to look in rows D7 through to D46
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi

Try:

Code:
Sub test()
For Each c In Range("D7:D46")
    If c.Value Like "21*" Then 
           c.EntireRow.Hidden = True
    Else
           c.EntireRow.Hidden = False
    End If
Next c
End Sub

You need to amend your criteria (I currently have it that it looks at the (text) value in D and if it begins 21 then the rwo gets hidden). If you want it to check for a specifc value then you can use:

Code:
If c.Value = 3 ....    'for a numeric
If c.Value = "Roger" ....   'for a text value

Hope this helps

Richard
 
Upvote 0

Forum statistics

Threads
1,215,456
Messages
6,124,939
Members
449,197
Latest member
k_bs

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