View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
tg tg is offline
external usenet poster
 
Posts: 58
Default how to hide a number of cells based on one cell?

THanks all of you for your quick and helful inputs!

"Rick Rothstein" wrote:

If Range("A1").Value = "no" Then
Range("A4:A15").EntireRow.Hidden = True
Else
Range("A4:A15").EntireRow.Hidden = False
End If


I thought you might be interested in knowing that the above 5 lines can be
replaced by this single line of code...

Range("A4:A15").EntireRow.Hidden = Range("A1").Value = "no"

--
Rick (MVP - Excel)


"Luke M" wrote in message
...
You can do that with the VBE. Right click on sheet tab, go to view code.
Paste this in, then close the editor:


Private Sub Worksheet_Change(ByVal Target As Range)

If Range("A1").Value = "no" Then
Range("A4:A15").EntireRow.Hidden = True
Else
Range("A4:A15").EntireRow.Hidden = False
End If

If Range("A19").Value = "no" Then
Range("A20:A100").EntireRow.Hidden = True
Else
Range("A20:A100").EntireRow.Hidden = False
End If

End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"TG" wrote:

Hello,

How would I be able to hide lets say row 4-15 if A1 had the word no?
Is this even possible? Also, what if i also want to hide rows 20-100 if
A19
says "no"?

Thank you in advance,

TG