Hiding cells within my range

tgick

New Member
Joined
Jan 7, 2008
Messages
15
I have a spreadsheet wherein I want to hide all rows in a set range if the the value in that row, column Y = "HIDE".

Below is the code I have written. I have a command just before this which sets My Range, depending on the value of a certain cell. Can anyone tell me why this does not work?

If MyRange.Address <> "$A$1" Then
For Each Cell In MyRange
Rows(Cell.Row).Hidden = UCase(Cell.Value) = "HIDE"
Next Cell
End If
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Maybe try:

Code:
If MyRange.Address <> "$A$1" Then
For Each Cell In MyRange
Cell.entireRow.Hidden = (UCase(Cell.Value) = "HIDE")
Next Cell
End If
Hope that helps.
 
Upvote 0
MyRange.Address is porbably not going to = $A$1 ever as hopefully since you are using a for loop MyRange is more than one cell. But that wouldn't effect the outcome. Can you post the whole code? Maybe try putting in a breakpoint and seeing what the value of cell is at each point in the code and walk through the code using F8?
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

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