Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Set value of checkbox on userform without triggering Click event

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Set value of checkbox on userform without triggering Click event

Sub ClearCheckBoxes()
'Me.ListBox1.Clear...for ListBoxes
Dim ChkBox As Object

For Each ChkBox In UserForm1.CheckBoxes
ChkBox.Value = xlOff
Next ChkBox

End Sub

Sub EnterCheckBoxes()
'Me.ListBox1.Clear...for ListBoxes
Dim ChkBox As Object

For Each ChkBox In UserForm1.CheckBoxes
ChkBox.Value = xlOn
Next ChkBox

End Sub

HTH
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jonathan Brown" wrote:

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Set value of checkbox on userform without triggering Click event

The code in the master checkbox (that sets the value of the others equal to
itself) should be put in the click event; the code for the other checkboxes
put in the MouseUp event this way clicking the master check wouldn't trigger
the code for the other check boxes.

I've try it and it works as expected unless if the code behind the other
check boxes is MsgBox then that will prevent the user from actually clicking
and changing the value of that check box.
--
A. Ch. Eirinberg


"Jonathan Brown" wrote:

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Set value of checkbox on userform without triggering Click eve

You guys are amazing. Seriously. What would I do without forums such as
this one?

"Howard31" wrote:

The code in the master checkbox (that sets the value of the others equal to
itself) should be put in the click event; the code for the other checkboxes
put in the MouseUp event this way clicking the master check wouldn't trigger
the code for the other check boxes.

I've try it and it works as expected unless if the code behind the other
check boxes is MsgBox then that will prevent the user from actually clicking
and changing the value of that check box.
--
A. Ch. Eirinberg


"Jonathan Brown" wrote:

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Set value of checkbox on userform without triggering Click eve

Ryan,

I'm having trouble using the Checkboxes collection of the Userform1. It
doesn't appear to be a valid collection. When I run the code I get an error
and it highlights that line.

I tried to modify it to look like below but it didn't work either.

Sub ClearCheckBoxes()
Dim ChkBox As Checkbox

For Each ChkBox In UserForm1.Controls
If ChkBox.ControlType = xlCheckbox Then
ChkBox.Value = xlOff
End If
Next ChkBox

End Sub

Is there some sort of a reference I need to include that I'm missing in
order for it to recognize the .CheckBoxes collection of the userform?

Thanks

"ryguy7272" wrote:

Sub ClearCheckBoxes()
'Me.ListBox1.Clear...for ListBoxes
Dim ChkBox As Object

For Each ChkBox In UserForm1.CheckBoxes
ChkBox.Value = xlOff
Next ChkBox

End Sub

Sub EnterCheckBoxes()
'Me.ListBox1.Clear...for ListBoxes
Dim ChkBox As Object

For Each ChkBox In UserForm1.CheckBoxes
ChkBox.Value = xlOn
Next ChkBox

End Sub

HTH
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jonathan Brown" wrote:

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Set value of checkbox on userform without triggering Click event

Another way is to use a variable that acts like application.enableevents would
for worksheet/workbook events.

Inside your userform module:
Option Explicit
Dim BlkProc As Boolean
Private Sub CheckBox1_Change()
BlkProc = True
If Me.CheckBox1.Value = True Then
Me.CheckBox2.Value = True
Me.CheckBox3.Value = True
End If
BlkProc = False
End Sub
Private Sub CheckBox2_Change()
If BlkProc = True Then Exit Sub
'other code here
End Sub
Private Sub CheckBox3_Change()
If BlkProc = True Then Exit Sub
'other code here
End Sub

Checkbox1 was my master checkbox.


Jonathan Brown wrote:

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Set value of checkbox on userform without triggering Click eve

Oh yeah, well that makes sense. Now, I'm wondering what
application.enableevents does exactly. Don't worry, you don't have to answer
that. I'll look it up. Thanks again!

"Dave Peterson" wrote:

Another way is to use a variable that acts like application.enableevents would
for worksheet/workbook events.

Inside your userform module:
Option Explicit
Dim BlkProc As Boolean
Private Sub CheckBox1_Change()
BlkProc = True
If Me.CheckBox1.Value = True Then
Me.CheckBox2.Value = True
Me.CheckBox3.Value = True
End If
BlkProc = False
End Sub
Private Sub CheckBox2_Change()
If BlkProc = True Then Exit Sub
'other code here
End Sub
Private Sub CheckBox3_Change()
If BlkProc = True Then Exit Sub
'other code here
End Sub

Checkbox1 was my master checkbox.


Jonathan Brown wrote:

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Set value of checkbox on userform without triggering Click eve

Excel is monitoring certain events (changes/recalculations/sheet
activations/...) all the time.

You can use these events to your advantage by tying into event procedures.

For instance, if you wanted a date/time stamp each time a typing change was made
in column A, you could use a worksheet event like the one JE McGimpsey shares:
http://www.mcgimpsey.com/excel/timestamp.html

Chip Pearson has some instructions on events:
http://www.cpearson.com/excel/events.htm

David McRitchie has some notes, too:
http://www.mvps.org/dmcritchie/excel/event.htm

There are application events, too.
You can read more about application events at Chip Pearson's site:
http://www.cpearson.com/excel/AppEvent.aspx

Jonathan Brown wrote:

Oh yeah, well that makes sense. Now, I'm wondering what
application.enableevents does exactly. Don't worry, you don't have to answer
that. I'll look it up. Thanks again!

"Dave Peterson" wrote:

Another way is to use a variable that acts like application.enableevents would
for worksheet/workbook events.

Inside your userform module:
Option Explicit
Dim BlkProc As Boolean
Private Sub CheckBox1_Change()
BlkProc = True
If Me.CheckBox1.Value = True Then
Me.CheckBox2.Value = True
Me.CheckBox3.Value = True
End If
BlkProc = False
End Sub
Private Sub CheckBox2_Change()
If BlkProc = True Then Exit Sub
'other code here
End Sub
Private Sub CheckBox3_Change()
If BlkProc = True Then Exit Sub
'other code here
End Sub

Checkbox1 was my master checkbox.


Jonathan Brown wrote:

I have a userform with several checkboxes on it. I have one "master"
checkbox that is supposed to be able to set all checkboxes true or false
based on its own state. So basically, if master checkbox is true then set
all checkboxes true, else if it's false then set all checkboxes false.

The annoying thing though is when it sets the value of each individual
checkbox it runs the code associated with each checkbox's click event. This
is slowing down my spreadsheet considerably.

Is it possible to set the value of a checkbox without Excel executing the
code associated with it's click event?


--

Dave Peterson


--

Dave Peterson
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
Click event for checkbox from Forms toolbar Carolyn Excel Discussion (Misc queries) 6 September 11th 06 08:16 PM
userform label double-click goes to click event John Paul Fullerton Excel Programming 3 May 19th 06 05:54 PM
Click Checkbox Event Montana DOJ Help Desk Excel Programming 4 November 11th 04 04:25 AM
Triggering click event of a menu in vba steve Excel Programming 4 August 19th 03 06:17 PM
Triggering click event of a menu in vba Tom Ogilvy Excel Programming 0 August 18th 03 07:51 PM


All times are GMT +1. The time now is 02:33 PM.

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"