VBA to hide a row

jeffmfrank

Board Regular
Joined
Feb 28, 2002
Messages
72
I'm a VBA rookie so I apologize if this is a simple procedure. What kind of code should I use to have a sheet automatically hide rows where the value in the column T for that row is "Y"? Can this always be running so that if "Y" changes to "N", the row is no longer hidden? Thanks.
 
this one works perfectly! EXCEPT it stops at row 61?? and how do I apply it to multiple sheets?
Like this?:
For Each c In Sheets("sheet1","sheet2").Range("T1", Range("T65536").End(xlUp).Address)
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
On 2002-03-06 15:44, jeffmfrank wrote:
this one works perfectly! EXCEPT it stops at row 61?? and how do I apply it to multiple sheets?
Like this?:
For Each c In Sheets("sheet1","sheet2").Range("T1", Range("T65536").End(xlUp).Address)
Is row 61 the last row in column T with data in it?

To apply it to multiple sheets use:
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Application.ScreenUpdating = False
For Each c In Sheets("Sheet1").Range("T1", Range("T65536").End(xlUp).Address)
    Select Case c.Value
    Case Is = "Y"
        c.EntireRow.Hidden = True
    Case Is = "N"
        c.EntireRow.Hidden = False
    End Select
Next c
For Each c In Sheets("Sheet2").Range("T1", Range("T65536").End(xlUp).Address)
    Select Case c.Value
    Case Is = "Y"
        c.EntireRow.Hidden = True
    Case Is = "N"
        c.EntireRow.Hidden = False
    End Select
Next c
Application.ScreenUpdating = True
End Sub

Again, note that this will really slow down performance if you have a lot of data in column T (in either sheet).

Regards,
 
Upvote 0
I can get rid of the row 61 problem although it's odd that it's occurring. The data only lies between T4:T80. Thanks for the help. This will work perfectly for my needs.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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