Conditional formatting - VBA

P

pls

i need instruction on a coding problem. i've determined it's not possible to
use conditional formatting to accomplish what i'm trying to achieve.

cell C23 is a drop down menu with choices "yes" and "no"
if c23 is no, i want rows 24-26 to be automatically hidden.

what is the VBA code for this, and how do i input it in the worksheet (step
by step)?
 
J

JE McGimpsey

One way:

Insert this in the worksheet code module (right-click the worksheet tab
and choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Range("24:26").EntireRow.Hidden = (LCase(Range("C23")) = "no")
End Sub
 
P

pls

Thanks! if i have additional conditions i want to add, how do i add that to
the code? for example, i tried to add the following before the End Sub, and
got an error:

Range("7:10").EntireRow.Hidden = (LCase(Range("D6")) = "new client")
 
Top