Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Macros for checkboxes

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

I think you may have solved the problem for me - thank you!
I will now go and see if it will work on multiple sheets with a number of
checkboxes.

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 527
Default Macros for checkboxes

Min

another way to hide an individual column.

Creat a list of the cols to hide, say on a new sheet. I used COls E to H

On the sheet you want to operate add a combo box, I linked it to A1. then I
assigned this macro.

Sub HideCol()
c = Range("A1") + 3
Columns(c).EntireColumn.Hidden = Not Columns(c).EntireColumn.Hidden
End Sub

Maybe this will help another time

Peter


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Macros for checkboxes

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Macros for checkboxes


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

You are an absolute star! Thank you so much for all your help!
Hopefully now, I can get on and finish this project.....


"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!



  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Macros for checkboxes

Macro1 to the checkboxes, Macro to the Option button.

Sorry ...I didn't explain this.

"Min" wrote:

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

My apologies for being a bit dim - especially when you are being so helpful.
How do I assign macro1 to all 6 checkboxes that already have their own
macros assigned to them anyway?
I tried grouping them with a group box and assigning macro1 to the group
box, but that doesn't work very well.



"Toppers" wrote:

Macro1 to the checkboxes, Macro to the Option button.

Sorry ...I didn't explain this.

"Min" wrote:

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

Aaah!! Yes! I've just done it!!

Many many thanks for all your help.
Cheers.
Min



"Min" wrote:

My apologies for being a bit dim - especially when you are being so helpful.
How do I assign macro1 to all 6 checkboxes that already have their own
macros assigned to them anyway?
I tried grouping them with a group box and assigning macro1 to the group
box, but that doesn't work very well.



"Toppers" wrote:

Macro1 to the checkboxes, Macro to the Option button.

Sorry ...I didn't explain this.

"Min" wrote:

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

Actually, I haven't - it doesn't work.



"Min" wrote:

Aaah!! Yes! I've just done it!!

Many many thanks for all your help.
Cheers.
Min



"Min" wrote:

My apologies for being a bit dim - especially when you are being so helpful.
How do I assign macro1 to all 6 checkboxes that already have their own
macros assigned to them anyway?
I tried grouping them with a group box and assigning macro1 to the group
box, but that doesn't work very well.



"Toppers" wrote:

Macro1 to the checkboxes, Macro to the Option button.

Sorry ...I didn't explain this.

"Min" wrote:

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Macros for checkboxes

If they already have macros assigned you need to add the code I supplied to
check if all 6 are checked. Or call macro from your existing macros.Will
this work?


Sub Your_macro()

Call macro1

......Your code

End Sub


This is the problem of working "blind" as I obviously only have a partial
picture of what you are doing.

"Min" wrote:

My apologies for being a bit dim - especially when you are being so helpful.
How do I assign macro1 to all 6 checkboxes that already have their own
macros assigned to them anyway?
I tried grouping them with a group box and assigning macro1 to the group
box, but that doesn't work very well.



"Toppers" wrote:

Macro1 to the checkboxes, Macro to the Option button.

Sorry ...I didn't explain this.

"Min" wrote:

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!



  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Min Min is offline
external usenet poster
 
Posts: 40
Default Macros for checkboxes

Yes it does work - thank you. I didn't realise that you could 'call' a macro,
I thought they always had to be assigned to something

Thank you for all your help - you have been very patient!
Regards
Min



"Toppers" wrote:

If they already have macros assigned you need to add the code I supplied to
check if all 6 are checked. Or call macro from your existing macros.Will
this work?


Sub Your_macro()

Call macro1

.....Your code

End Sub


This is the problem of working "blind" as I obviously only have a partial
picture of what you are doing.

"Min" wrote:

My apologies for being a bit dim - especially when you are being so helpful.
How do I assign macro1 to all 6 checkboxes that already have their own
macros assigned to them anyway?
I tried grouping them with a group box and assigning macro1 to the group
box, but that doesn't work very well.



"Toppers" wrote:

Macro1 to the checkboxes, Macro to the Option button.

Sorry ...I didn't explain this.

"Min" wrote:

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

  #17   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Macros for checkboxes

Glad we got there!

"Min" wrote:

Yes it does work - thank you. I didn't realise that you could 'call' a macro,
I thought they always had to be assigned to something

Thank you for all your help - you have been very patient!
Regards
Min



"Toppers" wrote:

If they already have macros assigned you need to add the code I supplied to
check if all 6 are checked. Or call macro from your existing macros.Will
this work?


Sub Your_macro()

Call macro1

.....Your code

End Sub


This is the problem of working "blind" as I obviously only have a partial
picture of what you are doing.

"Min" wrote:

My apologies for being a bit dim - especially when you are being so helpful.
How do I assign macro1 to all 6 checkboxes that already have their own
macros assigned to them anyway?
I tried grouping them with a group box and assigning macro1 to the group
box, but that doesn't work very well.



"Toppers" wrote:

Macro1 to the checkboxes, Macro to the Option button.

Sorry ...I didn't explain this.

"Min" wrote:

Sorry, I thought I understood this, but I can't seem to make it work.
What do I assign the 2 macros to?

"Toppers" wrote:


If you check all 6 Checkboxes, the option button isset to TRUE and if you
then uncheck one (or more) of the Check buttons, the Option button is set
off. If Option button selected, all Checkboxes are selected.

Is this OK?

C1:H1 are link cells .for Checkboxes ...

Sub Macro1()
' Check Checkboxes ....
If Application.CountIf(Range("C1:H1"), "TRUE") = 6 Then
Range("B1") = 1
Else
Range("B1") = 0
End If
End Sub

B1 is link cell for Option button

Sub Macro2()
' Check Option button ....
If Range("B1") = 1 Then
Range("C1:H1") = TRUE
End If


End Sub
"Min" wrote:

Yes, this works. Thank you. But...
I have 6 checkboxes that hide or unhide different columns. I also have an
option button to 'show all'. If the user selects all 6 checkboxes then I want
the option button to be true, otherwise it remains false.
Similarly, if the user selects the option button then I want all 6
checkboxes to be true. Is this possible?


"Toppers" wrote:

Link the Option Button to the same cell as the Checkbox .. no other macro
required. The Checkbox will set the state of the Option button.

HTH

"Min" wrote:

Can I also add into the macro something that will make an option button true
when the checkbox is true, and vice versa?

"Toppers" wrote:

I placed a checkbox from the FORMS toobar on a worksheet with C1 as a linked
cell: this shows TRUE/FALSE. It called the following macro in a general
module which hid/unhid columns OK.

Sub Macro1()
Columns("C:F").EntireColumn.Hidden = Range("C1")
End Sub


Does this help?

"Min" wrote:

I'm stilll really struggling with my checkboxes!
How do I write a macro that will show columns on a worksheet when the box is
selected, and hide the columns again when it is deselected?
Many thanks to Dave who has already tried to help, but I need simple
instructions!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
checkboxes helpless101 Excel Worksheet Functions 0 April 10th 06 11:54 AM
Checkboxes Randy L Excel Discussion (Misc queries) 3 February 22nd 06 08:09 PM
Checkboxes and macros danielle Excel Discussion (Misc queries) 7 June 14th 05 03:07 AM
Checkboxes Es Excel Discussion (Misc queries) 1 March 14th 05 02:07 PM
Checkboxes chuck Excel Discussion (Misc queries) 1 January 25th 05 03:48 AM


All times are GMT +1. The time now is 06:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"