Thread: VB code
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default VB code

hi
you might have better luck putting the code in the check box itself. here is
an example some old code i wrote several years ago to hide/unhide
metric/english measurments.
Private Sub ChBx1_Click()
If Columns("C:C").Hidden = True Then
Columns("C:C").Hidden = False
ChBx1.BackColor = RGB(0, 0, 255)
ChBx1.ForeColor = RGB(245, 245, 5)
ChBx1.Caption = "Metric"
Columns("D:D").Hidden = True
Else
Columns("C:C").Hidden = True
Columns("D:D").Hidden = False
ChBx1.BackColor = RGB(245, 30, 5)
'ChBx1.ForeColor =
ChBx1.Caption = "English"
End If
End Sub
I not only hid and unhide the columns, i also change the back color, text
color and captions.

worked great just by clicking.

Regards,
FSt1
"tom" wrote:

Good day.

I have created check boxes that control hiding and unhiding columns and rows
in one workbook writing the following code to control the hiding and unhiding.

Private Sub Worksheet_Calculate()

If Range("b5").Value = False Then
Columns("c:p").EntireColumn.Hidden = True
Else
Columns("c:p").EntireColumn.Hidden = False
End If

End Sub

I have since opened a new workbook, created another checkbox and used the
same code with absolutely no luck. I have checked my Macro settings in both,
which are both set to "low".

I am completely baffled.

Any suggestions?
--
Tom