View Single Post
  #16   Report Post  
William
 
Posts: n/a
Default

1. Use your mouse to hover over the toolbars, right-click and select
"Customise". Select the Command tab and then select "Drawing" from the
"Categories" section. From the "Commands" section, select "Drawing Objrcts"
and drag the icon to one of your toolbars. Click "Close" to return to the
Excel sheet.

2. Select the "Drawing Objects" icon from your toolbar and then select the
check-boxes which will be effected by your code. Hover over one of the
selected checkboxes and select "GroupingGroup". Either accept the name
given to the group in the "Name" box or create your own name for the group.

3. Since cell C4 is being changed via a check box, use the "Calculate"
event....

Private Sub Worksheet_Calculate()
With Sheets("Sheet1")
If .Range("C4").Value = True Then
..Range("C7:M19").EntireRow.Hidden = False
..Shapes("cbgroup").Visible = True
Else
..Range("C7:M19").EntireRow.Hidden = True
..Shapes("cbgroup").Visible = False
End If
End With
End Sub

But if it is the check boxes that cause C4 to change, how are you going to
change the check box if it is hidden?
-----
XL2003
Regards

William



"William" wrote in message
...
Pennington

Firstly, dont use the "Calculate" event, use the "Change" event to execute
your code.

In answer to your post, select all the checkboxes that you want to be
hidden / visible when you execute your code to hide / unhide rows and give
a name to that selection of checkboxes - In my example I have used
"cbgroup".

Private Sub Worksheet_Change(ByVal Target As Range)
With Sheets("ProcessA")
If Not Target(1).Address = .Range("C4").Address Then Exit Sub
.Range("C7:M19").EntireRow.Hidden = False
.Shapes("cbgroup").Visible = True
If .Range("C4").Value = False Then
.Range("C7:M19").EntireRow.Hidden = True
.Shapes("cbgroup").Visible = False
End If
End With
End Sub

--

-----
XL2003
Regards

William



"Pennington" wrote in message
...
William
I have now got it to work using the sheetcalculate command and have
decided
to hide rows rather than columns but I have got another problem. The True
and
False values are produced from check boxes but when the rows are hidden
the
check boxes are not - they all move down onto the unhidden rows. How can
I
hide the check boxes or is there another way of selecting a value by the
click of a mouse?

"William" wrote:

Pennington

Place the code in the "ThisWorkbook" module, NOT a general module.

-----
XL2003
Regards

William



"Pennington" wrote in message
...
Thank William but I can't get it to work. I have placed this code in
Module 1
of the workbook
Private Sub Workbook_Open()
With Sheets("ProcessA")
Range("E3:M3").EntireColumn.Hidden = False
If .Range("C4").Value = False Then _
Range("E3:M3").EntireColumn.Hidden = True
End With
End Sub
Saved the file closed and opening it but all the columns are still
showing

"William" wrote:

Hi..

Private Sub Workbook_Open()
With Sheets("Sheet1")
..Range("E3:M3").EntireColumn.Hidden = False
If .Range("C4").Value = False Then _
..Range("E3:M3").EntireColumn.Hidden = True
End With
End Sub

-----
XL2003
Regards

William




"Pennington" wrote in message
...
I am trying to hide a range of cells when the value in another cell
is
FALSE
and show the range of cells when the value is TRUE. My code is as
follows
but
it doesn't work
Private Sub Workbook_Open()
If Range("C4").Value = False Then
Range("E4:M40").Hide = True
End If
If Range("C4").Value = True Then
Range("E4:M40").Unhide = False
End Sub

How do I make this work?