PDA

View Full Version : [SOLVED:] Hide row if cell contains...



Pawel
07-27-2016, 04:48 AM
Hi,
I'm trying to create macro that hides rows if cell contains certain word.
The problem is that macro should only hide those rows that contain this cell.
As for now I have sth like this but it's not working:


Dim rng As Range
Set rng = Range("B1:B100")

For Each Cell In rng
If InStr(1, rng, "low") Then Cells(rng).EntireRow.Hidden = True
Next Cell

Please help.

GTO
07-27-2016, 05:11 AM
Try:


Option Explicit

Sub example()
Dim rng As Range
Dim Cell As Range

Set rng = Range("B1:B100")

For Each Cell In rng
If InStr(1, Cell, "low") Then Cell.EntireRow.Hidden = True
Next Cell
End Sub

Does that help?

Mark

Pawel
07-27-2016, 05:37 AM
It does help!
Thank you Mark (GTO)

GTO
07-27-2016, 05:40 AM
You are most welcome and thank you for the feedback :beerchug: