View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default how to hide a number of cells based on one cell?

To make a pun... it seems quite logical to me.<g Since you are testing if
Range("A1").Value is True or False and then assigning whichever to the
Hidden property of the specified range, then we might as well make the
assignment directly and do away with the intermediate test.

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Very Clever!
--
Gary''s Student - gsnu200858


"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