PDA

View Full Version : Solved: Help with simple Macro (I'm sure)



Gidday
05-28-2010, 04:10 AM
Hi Folks

I am using Excel 2007. I have almost no experience with VBA macros so I'm asking for a little help. I need a macro so that when I enter the word Quote into cell A4 rows 23:30 hide. If A4 contains anything else, including nothing/null, then the rows are to remain visible.

I'm sure this is simple but the answer is not within my current skills.

Thanks for any help

Joe

Bob Phillips
05-28-2010, 04:24 AM
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A4" '<== change to suit
Dim CI As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

With Target

Me.Rows("23:30").Hidden = .Value2 = "Quote"
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 on the sheet tab, select
the View Code option from the menu, and paste the code in.

Gidday
05-29-2010, 04:11 AM
Hi xld

Awesome. Works a treat.

Thanks

Joe