Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to reference a vba chkbox from a vba command button on excel?
Hi,
I have a vba command button and checkbox on an excel spreadsheet. How can I reference the chkbox from the click event of the command button. I would like to turn it on and off from the click event of the command button. Both are from the vba toolbox and both are directly on the spreadsheet and not on a vb form. I don't know if this is possible but if it is it would be very helpful to me thanks' Sterl |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to reference a vba chkbox from a vba command button on excel?
Something like:
Option Explicit Private Sub CommandButton1_Click() If Me.CheckBox1.Value = True Then MsgBox "It's checked" Else MsgBox "It's not checked" End If End Sub Change the names to match your buttons and checkboxes. Sterl wrote: Hi, I have a vba command button and checkbox on an excel spreadsheet. How can I reference the chkbox from the click event of the command button. I would like to turn it on and off from the click event of the command button. Both are from the vba toolbox and both are directly on the spreadsheet and not on a vb form. I don't know if this is possible but if it is it would be very helpful to me thanks' Sterl -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to reference a vba chkbox from a vba command button on excel?
Hi Sterl,
Try something like: '============= Private Sub CommandButton1_Click() With Me.CheckBox1 .Value = Not .Value End With End Sub '<<============= --- Regards, Norman "Sterl" wrote in message ups.com... Hi, I have a vba command button and checkbox on an excel spreadsheet. How can I reference the chkbox from the click event of the command button. I would like to turn it on and off from the click event of the command button. Both are from the vba toolbox and both are directly on the spreadsheet and not on a vb form. I don't know if this is possible but if it is it would be very helpful to me thanks' Sterl |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to reference a vba chkbox from a vba command button on excel?
Hi Dave,
Your suggestion worked fine...didn't know about the Me...I'm a bit new at this. thanks, Sterl Sterl wrote: Hi, I have a vba command button and checkbox on an excel spreadsheet. How can I reference the chkbox from the click event of the command button. I would like to turn it on and off from the click event of the command button. Both are from the vba toolbox and both are directly on the spreadsheet and not on a vb form. I don't know if this is possible but if it is it would be very helpful to me thanks' Sterl |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to reference a vba chkbox from a vba command button on excel?
Hi Norman,
I tried your solution and it worked fine. I also then tried to do the same from a vba form to get the same chkbox but instead of Me I used with ActiveSheet and it worked fine too. Thanks for the idea, Sterl Norman Jones wrote: Hi Sterl, Try something like: '============= Private Sub CommandButton1_Click() With Me.CheckBox1 .Value = Not .Value End With End Sub '<<============= --- Regards, Norman "Sterl" wrote in message ups.com... Hi, I have a vba command button and checkbox on an excel spreadsheet. How can I reference the chkbox from the click event of the command button. I would like to turn it on and off from the click event of the command button. Both are from the vba toolbox and both are directly on the spreadsheet and not on a vb form. I don't know if this is possible but if it is it would be very helpful to me thanks' Sterl |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VB's Command Button vs Form's Command Button | Excel Programming | |||
how to use a command button in excel? | Excel Programming | |||
Command Button in Excel | Excel Programming | |||
enable/disable start button on basis of chkbox conditions | Excel Programming | |||
excel, vba, command button | Excel Programming |