Hide/Unhide Selected Rows

ciaran3

New Member
Joined
Apr 24, 2015
Messages
8
Should be fairly simple (think I'm just having a brain fart) - I want to hide/unhide certain rows based on cells values in another table (and I'd iterate through this table) to hide/unhide throughout the document.

Cells(2,y) is the starting row, Cells(3,y) is the ending row - I want to hide all rows between those two values (eg Cells(2,y) = 10, Cells (3,y) = 20, hide rows 10-20).

Just missing something obvious in the bolded row.

For x = 4 To 10
For y = 6 To 10
If Sheets("Data").Cells(x, y) = "X" Then
Rows(Cells(2, y),Cells(3,y)).EntireRow.Hidden = True
End If
Next y
Next x
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try
Code:
Rows(Cells(2, y) [COLOR=#0000ff]& ":" &[/COLOR] Cells(3, y)).EntireRow.Hidden = True
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,860
Members
449,472
Latest member
ebc9

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