PDA

View Full Version : Hide Rows Using Data Validation



gnod
02-12-2007, 08:55 AM
Hi,

how can i hide/unhide rows using data validation.. if i select weekly, only the weekly rows should be visible..

thanks..

Bob Phillips
02-12-2007, 09:46 AM
You can't. Data validation will control input into a cell, it doesn't change the environment. You need event code for that.

gnod
02-12-2007, 10:10 AM
:(

maybe i can use buttons for weekly and monthly.. or do you have any other good idea..

thanks..

Bob Phillips
02-12-2007, 10:14 AM
Yeah, event code like I said before





Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B2" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Range("A1:A100").AutoFilter field:=1, Criteria1:=.Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click

gnod
02-12-2007, 10:39 AM
i like to use the

EntireRow.Hidden = True EntireRow.Hidden = False
instead of autofilter.. where will i put the code?

thanks..