You must be using a check box from the control toolbox. In this case
you want to make sure that you are in design mode (ie the design mod
icon on your control toolbox toolbar is selected). In design mode
right click on your checkbox and view code. Copy and paste this ove
the existing code and it should work fine.
Private Sub CheckBox1_Click()
Dim r As Range
Set r = Range("J1:K1")
r.EntireColumn.Hidden = Not r.EntireColumn.Hidden
End Sub
Note: Make sure the name of your checkbox is CheckBox1. If not, yo
will need to edit the name of the checkbox in the above code t
correspond with the name of your checkbox.
I've found this aplication to be very usefull to keep my Worksheets ver
"clean".
Now I want to do the same (be shown or hiden when clicked) but fo
rows, lets say rows 4 to 10, what do I have to change in the code t
make this happen??.
I'll place the checkbox in A1, when clicked, I want cell A3 to b
selected and then rows 4 to 10 be shown or hiden.
It's pretty much the same code. The only change will be the rang
(obviously) and what you are hiding. Last time you wanted to hide th
"EntireColumn", this time you want to hide the "EntireRow". You als
want A3 to be selected after they are hidden/unhidden. What you nee
to do is call up the cell and select it (ie Range("A3").Select).
Private Sub CheckBox1_Click()
Dim r As Range
Set r = Range("A4:A10")
r.EntireRow.Hidden = Not r.EntireRow.Hidden
Range("A3").Select
End Su
To be honest with you, I've only started working in VBA a little over
month ago. I never took a class and I never read a book on it. Th
higher-ups at my job want me to build a database but they don't want t
show me how. I thought it would be worth while to try and figure ou
how to write code in VBA. This forum is the best place I can find fo
useful information. I also heard that books like "VBA for Dummies
are very helpful for beginners. I'm just too cheap to dish out the $5
or so
Private Sub CheckBox1_Click()
if checkbox1.value = true then
Range("A4:A10").EntireRow.Hidden = true
Else
Range("A4:A10").EntireRow.Hidden = false
End Sub
Also this should be more comprehensible for somebody that just starte
working with VBA
Private Sub CheckBox1_Click()
if checkbox1.value = true then
Range("A4:A10").EntireRow.Hidden = true
Else
Range("A4:A10").EntireRow.Hidden = false
End if
End Su