Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
nemadrias
 
Posts: n/a
Default Simple Checkbox Message Code


Hey -
Somewhat newbie to VBA - Can anyone tell me what is wrong with this
code?
Error is "Object doesn't support this method". Thanks a ton.
Steve

Sub CheckBoxChange()
If ActiveSheet.CheckBox2.Value = True Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = False
End If
ElseIf ActiveSheet.CheckBox2.Value = False Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = True
End If
End If
End Sub


--
nemadrias
------------------------------------------------------------------------
nemadrias's Profile: http://www.excelforum.com/member.php...o&userid=24613
View this thread: http://www.excelforum.com/showthread...hreadid=552736

  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Simple Checkbox Message Code

Are you using the CheckBox control from the Controls toolbar? Is
you check box actually named CheckBox2?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"nemadrias"
wrote in
message
...

Hey -
Somewhat newbie to VBA - Can anyone tell me what is wrong with
this
code?
Error is "Object doesn't support this method". Thanks a ton.
Steve

Sub CheckBoxChange()
If ActiveSheet.CheckBox2.Value = True Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = False
End If
ElseIf ActiveSheet.CheckBox2.Value = False Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = True
End If
End If
End Sub


--
nemadrias
------------------------------------------------------------------------
nemadrias's Profile:
http://www.excelforum.com/member.php...o&userid=24613
View this thread:
http://www.excelforum.com/showthread...hreadid=552736



  #3   Report Post  
Posted to microsoft.public.excel.misc
nemadrias
 
Posts: n/a
Default Simple Checkbox Message Code


Chip -
I'm actually using it from the forms toolbar. But it is called
CheckBox2.

Chip Pearson Wrote:
Are you using the CheckBox control from the Controls toolbar? Is
you check box actually named CheckBox2?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"nemadrias"
wrote in
message
...

Hey -
Somewhat newbie to VBA - Can anyone tell me what is wrong with
this
code?
Error is "Object doesn't support this method". Thanks a ton.
Steve

Sub CheckBoxChange()
If ActiveSheet.CheckBox2.Value = True Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = False
End If
ElseIf ActiveSheet.CheckBox2.Value = False Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = True
End If
End If
End Sub


--
nemadrias

------------------------------------------------------------------------
nemadrias's Profile:
http://www.excelforum.com/member.php...o&userid=24613
View this thread:
http://www.excelforum.com/showthread...hreadid=552736



--
nemadrias
------------------------------------------------------------------------
nemadrias's Profile: http://www.excelforum.com/member.php...o&userid=24613
View this thread: http://www.excelforum.com/showthread...hreadid=552736

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Simple Checkbox Message Code

So the macro is in a general module and it's assigned to that checkbox?

Option Explicit
Sub CheckBoxChange()
Dim myCBX As CheckBox
Dim myOtherCBX As CheckBox

'the one you just changed
Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)
Set myOtherCBX = ActiveSheet.CheckBoxes("Checkbox2")

If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
If myCBX.Value = xlOn Then
myOtherCBX.Value = xlOff
Else
myOtherCBX.Value = xlOn
End If
Else
If myCBX.Value = xlOn Then
myCBX.Value = xlOff
Else
myCBX.Value = xlOn
End If

End If

End Sub

The checkbox names are pretty unusual for checkboxes from the Forms toolbar and
I'm not sure I'd have one checkbox control another one (why not just use that
single checkbox), but I think that this works.

nemadrias wrote:

Chip -
I'm actually using it from the forms toolbar. But it is called
CheckBox2.

Chip Pearson Wrote:
Are you using the CheckBox control from the Controls toolbar? Is
you check box actually named CheckBox2?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"nemadrias"
wrote in
message
...

Hey -
Somewhat newbie to VBA - Can anyone tell me what is wrong with
this
code?
Error is "Object doesn't support this method". Thanks a ton.
Steve

Sub CheckBoxChange()
If ActiveSheet.CheckBox2.Value = True Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = False
End If
ElseIf ActiveSheet.CheckBox2.Value = False Then
If MsgBox("Do you really want to change the risk level?", _
vbQuestion + vbYesNo) = vbYes Then
ActiveSheet.CheckBox2.Value = True
End If
End If
End Sub


--
nemadrias

------------------------------------------------------------------------
nemadrias's Profile:
http://www.excelforum.com/member.php...o&userid=24613
View this thread:
http://www.excelforum.com/showthread...hreadid=552736


--
nemadrias
------------------------------------------------------------------------
nemadrias's Profile: http://www.excelforum.com/member.php...o&userid=24613
View this thread: http://www.excelforum.com/showthread...hreadid=552736


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
nemadrias
 
Posts: n/a
Default Simple Checkbox Message Code


Hey -
Thanks so much for your help so far. That does execute, but I think I
explained what I'm trying to do badly. If any certain checkboxes out
of (N number of) checkboxes are checked, I want to be able to ask if
the user really wants to change TO THAT checkbox and then uncheck the
others of the group. So, for instance, in a group of 3 checkboxes, if
the first is checked and the user checks the 3rd, it will ask for
confirmation, uncheck the first, then check the third. Can you give me
some assistance with that? Thanks again, and sorry for the lack of
clarity.
Steve


--
nemadrias
------------------------------------------------------------------------
nemadrias's Profile: http://www.excelforum.com/member.php...o&userid=24613
View this thread: http://www.excelforum.com/showthread...hreadid=552736



  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Simple Checkbox Message Code

I'm not sure I understand, but as a user, I think I would rather click on the
checkboxes themselves to change them--rather than answering several prompts that
ask me a question about each checkbox.

Are you trying to have a "master" checkbox that turns all the other checkboxes
on or off?

And if you are, how many checkboxes does that master checkbox control and how
many groups are there?

nemadrias wrote:

Hey -
Thanks so much for your help so far. That does execute, but I think I
explained what I'm trying to do badly. If any certain checkboxes out
of (N number of) checkboxes are checked, I want to be able to ask if
the user really wants to change TO THAT checkbox and then uncheck the
others of the group. So, for instance, in a group of 3 checkboxes, if
the first is checked and the user checks the 3rd, it will ask for
confirmation, uncheck the first, then check the third. Can you give me
some assistance with that? Thanks again, and sorry for the lack of
clarity.
Steve

--
nemadrias
------------------------------------------------------------------------
nemadrias's Profile: http://www.excelforum.com/member.php...o&userid=24613
View this thread: http://www.excelforum.com/showthread...hreadid=552736


--

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
Message box if cell is greater than less than 0 [Zero] SG Excel Discussion (Misc queries) 9 May 18th 06 10:42 PM
code break message box freekrill Excel Discussion (Misc queries) 2 November 29th 05 05:26 PM
Mocro code for sending a worksheet in a mail message Lorenzo Excel Discussion (Misc queries) 1 August 31st 05 10:49 PM
What is the VBA code to delete a sheet without warning message? [email protected] Excel Discussion (Misc queries) 2 August 9th 05 04:16 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 4th 05 10:50 AM


All times are GMT +1. The time now is 08:11 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"