ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Hide Rows based on conditional value in cell (https://www.excelbanter.com/excel-programming/299032-how-hide-rows-based-conditional-value-cell.html)

Nick

How to Hide Rows based on conditional value in cell
 
Hi,

I have seen lots of examples but can't get any to work - I have a job
sheet with approx 60 rows - the rows contain data applicable to
various types of job.

What I want to do is have the user select which job type they are
completing, and then automatically hide/unhide the rows that aren't
relevant to that job.

I have added a hidden column A with an If statement that returns 1 or
0 depending on if the row should be shown/hidden 1 to show - 0 to
hide)based on what the user picks as the job type.

Can anyone help with some sample code and maybe advice on how I can
get this to work ?

Thanks..
Nick

yogendra joshi

How to Hide Rows based on conditional value in cell
 
you can use worksheet_change event to control the same.

For example if you want to do this based on your hidden A row

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Range("A5:A60")
If cell.Value = 0 Then
cell.EntireRow.Hidden = True
ElseIf cell.Value = 1 Then
cell.EntireRow.Hidden = False
End If
Next
Application.ScreenUpdating = True
End Sub



Nick wrote:

Hi,

I have seen lots of examples but can't get any to work - I have a job
sheet with approx 60 rows - the rows contain data applicable to
various types of job.

What I want to do is have the user select which job type they are
completing, and then automatically hide/unhide the rows that aren't
relevant to that job.

I have added a hidden column A with an If statement that returns 1 or
0 depending on if the row should be shown/hidden 1 to show - 0 to
hide)based on what the user picks as the job type.

Can anyone help with some sample code and maybe advice on how I can
get this to work ?

Thanks..
Nick




All times are GMT +1. The time now is 08:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com