Conditional formatting - VBA

  • Thread starter Thread starter pls
  • Start date Start date
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)?
 
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
 
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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top