Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
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
VB's Command Button vs Form's Command Button Ronald Dodge Excel Programming 3 May 24th 06 02:23 PM
how to use a command button in excel? GailK Excel Programming 1 April 30th 06 03:17 PM
Command Button in Excel Frederic Excel Programming 14 November 16th 05 12:50 AM
enable/disable start button on basis of chkbox conditions ilyaskazi[_7_] Excel Programming 6 June 4th 05 09:09 AM
excel, vba, command button jimx[_2_] Excel Programming 2 June 1st 04 05:38 PM


All times are GMT +1. The time now is 03:54 AM.

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

About Us

"It's about Microsoft Excel"