Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 2pcs of code, a button & a checkbox

Hi,

I have two pieces of code, a button and a checkbox.

I would like to be able to have the button operate one
piece of code should the checkbox be checked or another
piece of code if it is left unchecked.

how would i lay it out?

Lynda.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 2pcs of code, a button & a checkbox

Assuming controls from the Control Toolbox Toolbar, use the click event for
the commandbutton
Private Sub Commandbutton1_Click()
if me.Checkbox1.Value = True then
' some code
else
' some other code
end if
End Sub

Post back if from the forms toolbar.

--
Regards,
Tom Ogilvy


"Lynda" wrote in message
...
Hi,

I have two pieces of code, a button and a checkbox.

I would like to be able to have the button operate one
piece of code should the checkbox be checked or another
piece of code if it is left unchecked.

how would i lay it out?

Lynda.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 2pcs of code, a button & a checkbox

Tom

I had to use the following code to get it to work

If ActiveSheet.DrawingObjects("Check Box 9").Value < 1
Then
etc.. etc..

how can I get the checkbox to reset on exit of the form
to make its state as unticked even if the last thing I
have done is tick it?

lynda

-----Original Message-----
Assuming controls from the Control Toolbox Toolbar, use

the click event for
the commandbutton
Private Sub Commandbutton1_Click()
if me.Checkbox1.Value = True then
' some code
else
' some other code
end if
End Sub

Post back if from the forms toolbar.

--
Regards,
Tom Ogilvy


"Lynda" wrote in

message
...
Hi,

I have two pieces of code, a button and a checkbox.

I would like to be able to have the button operate one
piece of code should the checkbox be checked or another
piece of code if it is left unchecked.

how would i lay it out?

Lynda.



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 2pcs of code, a button & a checkbox

If ActiveSheet.Checkboxes("Check Box 9").Value = xloff then ' or xlOn for
checked

How do you exit the form? (I assume by form you mean a worksheet that you
have laid out to look like a paper form).

I you mean select another sheet then perhaps right click on the sheet tab
and select view code. In the resulting code module Put in code like

Private Sub Worksheet_Deactivate()
Me.CheckBoxes("Check Box 9").Value = xlOff
End Sub


--
Regards,
Tom Ogilvy

"Lynda" wrote in message
...
Tom

I had to use the following code to get it to work

If ActiveSheet.DrawingObjects("Check Box 9").Value < 1
Then
etc.. etc..

how can I get the checkbox to reset on exit of the form
to make its state as unticked even if the last thing I
have done is tick it?

lynda

-----Original Message-----
Assuming controls from the Control Toolbox Toolbar, use

the click event for
the commandbutton
Private Sub Commandbutton1_Click()
if me.Checkbox1.Value = True then
' some code
else
' some other code
end if
End Sub

Post back if from the forms toolbar.

--
Regards,
Tom Ogilvy


"Lynda" wrote in

message
...
Hi,

I have two pieces of code, a button and a checkbox.

I would like to be able to have the button operate one
piece of code should the checkbox be checked or another
piece of code if it is left unchecked.

how would i lay it out?

Lynda.



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 2pcs of code, a button & a checkbox

Thanks Tom,

Thats just what I needed.

L.


-----Original Message-----
If ActiveSheet.Checkboxes("Check Box 9").Value = xloff

then ' or xlOn for
checked

How do you exit the form? (I assume by form you mean a

worksheet that you
have laid out to look like a paper form).

I you mean select another sheet then perhaps right click

on the sheet tab
and select view code. In the resulting code module Put

in code like

Private Sub Worksheet_Deactivate()
Me.CheckBoxes("Check Box 9").Value = xlOff
End Sub


--
Regards,
Tom Ogilvy

"Lynda" wrote in

message
...
Tom

I had to use the following code to get it to work

If ActiveSheet.DrawingObjects("Check Box 9").Value < 1
Then
etc.. etc..

how can I get the checkbox to reset on exit of the form
to make its state as unticked even if the last thing I
have done is tick it?

lynda

-----Original Message-----
Assuming controls from the Control Toolbox Toolbar,

use
the click event for
the commandbutton
Private Sub Commandbutton1_Click()
if me.Checkbox1.Value = True then
' some code
else
' some other code
end if
End Sub

Post back if from the forms toolbar.

--
Regards,
Tom Ogilvy


"Lynda" wrote in

message
...
Hi,

I have two pieces of code, a button and a checkbox.

I would like to be able to have the button operate

one
piece of code should the checkbox be checked or

another
piece of code if it is left unchecked.

how would i lay it out?

Lynda.


.



.



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
Shrinking Checkbox and Radio Button Dennis C BroadWare Excel Discussion (Misc queries) 0 November 10th 06 03:01 PM
Checkbox and button snag sungen99[_10_] Excel Programming 0 October 8th 04 06:40 PM
Checkbox and button snag K Dales Excel Programming 0 October 8th 04 06:03 PM
properties of excel button/checkbox yaniv Excel Programming 1 August 6th 04 03:16 AM
Button Enabling based on check in checkbox Todd Huttenstine[_2_] Excel Programming 2 November 25th 03 04:56 AM


All times are GMT +1. The time now is 09:15 PM.

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"