Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

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
enable/disable button based on cell value Shoney Excel Discussion (Misc queries) 3 January 9th 08 07:34 PM
Enable / Disable a button using a macro SapnaT Excel Programming 0 November 26th 04 09:56 AM
how to enable / disable customised button on toolbar tango Excel Programming 0 October 23rd 04 12:19 AM
How to enable/disable a button. Polly[_3_] Excel Programming 2 May 28th 04 04:24 AM
Enable/Disable Button surplusbc[_6_] Excel Programming 1 February 1st 04 09:53 PM


All times are GMT +1. The time now is 02:19 AM.

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"