![]() |
enable/disable start button on basis of chkbox conditions
I hv various chkboxes on my userform. If any of this chkbox value is true then enable the "START" button else disable. Plz note: One chkbox is to select and deselect all other chkboxes. Also if any other chkbox value is set to false, then the chkbox(select-deselect all) becomes false. Example file is attached with codes of selecting/deselecting all. I required now this to reflect accordingly to "Start" button to enable/disable. +-------------------------------------------------------------------+ |Filename: Book3.zip | |Download: http://www.excelforum.com/attachment.php?postid=3451 | +-------------------------------------------------------------------+ -- ilyaskazi ------------------------------------------------------------------------ ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969 View this thread: http://www.excelforum.com/showthread...hreadid=376218 |
enable/disable start button on basis of chkbox conditions
Assuming that the button is called cmdStart
Option Explicit Private mEnableEvents As Boolean Private Sub CheckBox1_Click() With Me If mEnableEvents Then mEnableEvents = False mEnableEvents = False .CheckBox2.Value = .CheckBox1.Value .CheckBox3.Value = .CheckBox1.Value .CheckBox4.Value = .CheckBox1.Value .CheckBox5.Value = .CheckBox1.Value .cmdStart.Enabled = True mEnableEvents = True End If End With End Sub Private Sub CheckBox2_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox2 End If End With End Sub Private Sub CheckBox3_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox3 End If End With End Sub Private Sub CheckBox4_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox4 End If End With End Sub Private Sub CheckBox5_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox5 End If End With End Sub Private Sub UserForm_Activate() mEnableEvents = True Me.cmdStart.Enabled = False End Sub Private Sub SetCheckboxes(thisCb As MSForms.CheckBox) With Me mEnableEvents = False If Not thisCb.Value Then .CheckBox1.Value = False .cmdStart.Enabled = False ElseIf .CheckBox2.Value And .CheckBox3.Value And _ .CheckBox4.Value And .CheckBox5.Value Then .CheckBox1.Value = True .cmdStart.Enabled = True End If mEnableEvents = True End With End Sub -- HTH Bob Phillips "ilyaskazi" wrote in message ... I hv various chkboxes on my userform. If any of this chkbox value is true then enable the "START" button else disable. Plz note: One chkbox is to select and deselect all other chkboxes. Also if any other chkbox value is set to false, then the chkbox(select-deselect all) becomes false. Example file is attached with codes of selecting/deselecting all. I required now this to reflect accordingly to "Start" button to enable/disable. +-------------------------------------------------------------------+ |Filename: Book3.zip | |Download: http://www.excelforum.com/attachment.php?postid=3451 | +-------------------------------------------------------------------+ -- ilyaskazi ------------------------------------------------------------------------ ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969 View this thread: http://www.excelforum.com/showthread...hreadid=376218 |
enable/disable start button on basis of chkbox conditions
Oops, I forget to say that if other all chkboxes value is false then dont set the cmdStart button as true. ALL CHKBOX is FALSE then cmdStart.enabled=false upon clicking any chkbox if other chkboxes value is true, then keep button enable. -- ilyaskazi ------------------------------------------------------------------------ ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969 View this thread: http://www.excelforum.com/showthread...hreadid=376218 |
enable/disable start button on basis of chkbox conditions
Option Explicit
Private mEnableEvents As Boolean Private Sub CheckBox1_Click() With Me If mEnableEvents Then mEnableEvents = False mEnableEvents = False .CheckBox2.Value = .CheckBox1.Value .CheckBox3.Value = .CheckBox1.Value .CheckBox4.Value = .CheckBox1.Value .CheckBox5.Value = .CheckBox1.Value If .CheckBox1.Value Then .cmdStart.Enabled = True End If mEnableEvents = True End If End With End Sub Private Sub CheckBox2_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox2 End If End With End Sub Private Sub CheckBox3_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox3 End If End With End Sub Private Sub CheckBox4_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox4 End If End With End Sub Private Sub CheckBox5_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox5 End If End With End Sub Private Sub UserForm_Activate() mEnableEvents = True Me.cmdStart.Enabled = False End Sub Private Sub SetCheckboxes(thisCb As MSForms.CheckBox) With Me mEnableEvents = False If Not thisCb.Value Then .CheckBox1.Value = False ElseIf .CheckBox2.Value And .CheckBox3.Value And _ .CheckBox4.Value And .CheckBox5.Value Then .CheckBox1.Value = True .cmdStart.Enabled = True End If If Not .CheckBox2.Value And Not .CheckBox3.Value And _ Not .CheckBox4.Value And Not .CheckBox5.Value Then .cmdStart.Enabled = False End If mEnableEvents = True End With End Sub -- HTH Bob Phillips "ilyaskazi" wrote in message ... Oops, I forget to say that if other all chkboxes value is false then dont set the cmdStart button as true. ALL CHKBOX is FALSE then cmdStart.enabled=false upon clicking any chkbox if other chkboxes value is true, then keep button enable. -- ilyaskazi ------------------------------------------------------------------------ ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969 View this thread: http://www.excelforum.com/showthread...hreadid=376218 |
enable/disable start button on basis of chkbox conditions
no no no.... output is not what i wanted. Let me clear you again... If i set value of chkbox1 = true then chkbox2=true chkbox3=true chkbox4=true chkbox5=true (set all other chkboxes=true) and cmdStart.enabled=true elseif i set value of chkbox1= false then chkbox2=false chkbox3=false chkbox4=false chkbox5=false (set all other chkboxes=false) and cmdStart.enabled=false Also.... if i set value of chkbox2=false then check value of othe chkboxes(3,4,5) and if value of all chkboxes(3,4,5)=false then cmdStart.enabled=false elseif any of the chkboxes(3,4,5)=true then cmdStart.enabled=true same for other chkboxes(3,4,5) check and apply. example is attached. plz see for reference +------------------------------------------------------------------- |Filename: Book6.zip |Download: http://www.excelforum.com/attachment.php?postid=3453 +------------------------------------------------------------------- -- ilyaskaz ----------------------------------------------------------------------- ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396 View this thread: http://www.excelforum.com/showthread.php?threadid=37621 |
enable/disable start button on basis of chkbox conditions
Sorry I couldn't help you.
Bob "ilyaskazi" wrote in message ... no no no.... output is not what i wanted. Let me clear you again... If i set value of chkbox1 = true then chkbox2=true chkbox3=true chkbox4=true chkbox5=true (set all other chkboxes=true) and cmdStart.enabled=true elseif i set value of chkbox1= false then chkbox2=false chkbox3=false chkbox4=false chkbox5=false (set all other chkboxes=false) and cmdStart.enabled=false Also.... if i set value of chkbox2=false then check value of other chkboxes(3,4,5) and if value of all chkboxes(3,4,5)=false then cmdStart.enabled=false elseif any of the chkboxes(3,4,5)=true then cmdStart.enabled=true same for other chkboxes(3,4,5) check and apply. example is attached. plz see for reference. +-------------------------------------------------------------------+ |Filename: Book6.zip | |Download: http://www.excelforum.com/attachment.php?postid=3453 | +-------------------------------------------------------------------+ -- ilyaskazi ------------------------------------------------------------------------ ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969 View this thread: http://www.excelforum.com/showthread...hreadid=376218 |
enable/disable start button on basis of chkbox conditions
Its ok. But your code has helped me solving it like this... Code: -------------------- Option Explicit Private mEnableEvents As Boolean Private Sub CheckBox1_Click() With Me If mEnableEvents Then mEnableEvents = False mEnableEvents = False .CheckBox2.Value = .CheckBox1.Value .CheckBox3.Value = .CheckBox1.Value .CheckBox4.Value = .CheckBox1.Value .CheckBox5.Value = .CheckBox1.Value SetCheckboxes .CheckBox1 If .CheckBox1.Value Then .cmdStart.Enabled = True End If mEnableEvents = True mEnableEvents = True End If End With End Sub Private Sub CheckBox2_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox2 If .CheckBox2.Value Then .cmdStart.Enabled = True End If End If End With End Sub Private Sub CheckBox3_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox3 If .CheckBox3.Value Then .cmdStart.Enabled = True End If End If End With End Sub Private Sub CheckBox4_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox4 If .CheckBox4.Value Then .cmdStart.Enabled = True End If End If End With End Sub Private Sub CheckBox5_Click() With Me If mEnableEvents Then SetCheckboxes .CheckBox5 If .CheckBox5.Value Then .cmdStart.Enabled = True End If End If End With End Sub Private Sub UserForm_Activate() mEnableEvents = True Me.cmdStart.Enabled = False End Sub Private Sub SetCheckboxes(thisCb As MSForms.CheckBox) With Me mEnableEvents = False If Not thisCb.Value Then .CheckBox1.Value = False ElseIf .CheckBox2.Value And .CheckBox3.Value And _ .CheckBox4.Value And .CheckBox5.Value Then .CheckBox1.Value = True .cmdStart.Enabled = True End If If Not .CheckBox2.Value And Not .CheckBox3.Value And _ Not .CheckBox4.Value And Not .CheckBox5.Value Then .cmdStart.Enabled = False End If mEnableEvents = True End With End Sub -------------------- and it is working fine according to my requirement. Plz check. -- ilyaskazi ------------------------------------------------------------------------ ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969 View this thread: http://www.excelforum.com/showthread...hreadid=376218 |
All times are GMT +1. The time now is 10:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com