VB code

T

tom

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?
 
F

FSt1

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
 
T

tom

Still no luck.

My code works in a seperate workbook I was working on yesterday and not in
the one I'm working on today.??
 
T

tom

I have also found that I am able to run the code with success from within my VB
code window.

Must be some minor glitch regarding allowing the checkbox to perform it's
duty.

Tom
 
F

FSt1

hi
sorry to take so long to get back. got hung up.
question. Why did you tie your code and the hiding and unhiding of columns
to the calculation event.? that confused me. am i missing something?
the calculation event is triggered by enter, paste, delete, F9, and others
which seemed random to me. you say that it works for you. could you explain
further.....please.
regards
FST1
 

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

Top