ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stop Problem (https://www.excelbanter.com/excel-programming/271439-stop-problem.html)

David W[_3_]

Stop Problem
 
I am trying to stop someone from continuing if they select 2 different
checkboxes until one of them are unchecked, I have been playing with this
and haven't got it to work,what are your thoughts other than me finding a
new job

Private Sub CheckBox2_Change()
Dim wksh As Worksheet
Set wksh = Worksheets("jan")
If CheckBox2.Value = True Then
If CheckBox6.Value = True Then
Stop
MsgBox "Please Uncheck Either Plant or Construction Before Proceeding"
Else
For i = 1 To 12
sname = Choose(i, "jan", "feb", "march", "april", "may", _
"june", "july", "aug", "sept", "oct", "nov", "dec")

Set wksh = Worksheets(sname)
wksh.Unprotect ("?")
wksh.Range("v10") = Me.CheckBox2.Value
wksh.Protect ("?")
Next
End If
End Sub



John Wilson

Stop Problem
 
David,

Try this:

Private Sub CheckBox2_Change()
Dim wksh As Worksheet
Set wksh = Worksheets("jan")
If CheckBox2.Value = True AND CheckBox6.Value = True Then
MsgBox "Please Uncheck Either Plant or Construction Before Proceeding"
Exit Sub
Else
For i = 1 To 12
sname = Choose(i, "jan", "feb", "march", "april", "may", _
"june", "july", "aug", "sept", "oct", "nov", "dec")

Set wksh = Worksheets(sname)
wksh.Unprotect ("?")
wksh.Range("v10") = Me.CheckBox2.Value
wksh.Protect ("?")
Next
End If
End Sub

John

David W wrote:

I am trying to stop someone from continuing if they select 2 different
checkboxes until one of them are unchecked, I have been playing with this
and haven't got it to work,what are your thoughts other than me finding a
new job

Private Sub CheckBox2_Change()
Dim wksh As Worksheet
Set wksh = Worksheets("jan")
If CheckBox2.Value = True Then
If CheckBox6.Value = True Then
Stop
MsgBox "Please Uncheck Either Plant or Construction Before Proceeding"
Else
For i = 1 To 12
sname = Choose(i, "jan", "feb", "march", "april", "may", _
"june", "july", "aug", "sept", "oct", "nov", "dec")

Set wksh = Worksheets(sname)
wksh.Unprotect ("?")
wksh.Range("v10") = Me.CheckBox2.Value
wksh.Protect ("?")
Next
End If
End Sub



Dave Peterson[_3_]

Stop Problem
 
Instead of using checkboxes, how about optionbuttons. If they're grouped
nicely, you select one, it unselects the other.

David W wrote:

I am trying to stop someone from continuing if they select 2 different
checkboxes until one of them are unchecked, I have been playing with this
and haven't got it to work,what are your thoughts other than me finding a
new job

Private Sub CheckBox2_Change()
Dim wksh As Worksheet
Set wksh = Worksheets("jan")
If CheckBox2.Value = True Then
If CheckBox6.Value = True Then
Stop
MsgBox "Please Uncheck Either Plant or Construction Before Proceeding"
Else
For i = 1 To 12
sname = Choose(i, "jan", "feb", "march", "april", "may", _
"june", "july", "aug", "sept", "oct", "nov", "dec")

Set wksh = Worksheets(sname)
wksh.Unprotect ("?")
wksh.Range("v10") = Me.CheckBox2.Value
wksh.Protect ("?")
Next
End If
End Sub


--

Dave Peterson



All times are GMT +1. The time now is 08:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com