If-Clause in VBA to look at checkbox if its checked or not

zorc

New Member
Joined
Apr 15, 2003
Messages
6
Hello!

let's say i have "check box 20" and i want to make an IF-clause to check, if this same box is checked or unchecked.

This makes it enabled i have figured out myself yay! ;)

ActiveSheet.Shapes("Check Box 20").Select
With Selection
.Value = xlOn

So Is it possible to make IF-clause to "sniff" that box if its checked or not?

Thanks a million!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hey all, I know this thread is ancient but I felt it better to revive an old thread then then go postal. Whatever genious at Micrococks that thought to himself, "Sure Emnthung, lets go ahead and approve the usage of 2 TOTALLY different checkbox methods and while we're at it lets not document anything about them and do all we can to remove search references concerning them. And Tynysac" "Yes Sir" "Make sure to remove any trace of compatiblity between them" "Will do sir" "Great...tossed salads for everyone" clearly has mommy issues.

I still have blood running from the corners of my mouth from biting my tounge to keep that as clean as i could...bottom line is that I have wasted a great deal of time for NO REASON.

The forms checkbox is better because it does not fk up the look on the spread sheet, I have the control toolbox checkbox set to transparent and it still distortes the lines.

Could someone go over the rational for such a decision s this one, to include two types of checkboxes?
 
Upvote 0
Conditionally format based on checking a check box

:confused: i've read this post. i have an =EMBED("Forms.CheckBox.1","")
that i'd like to see if it's got a check in it, and if it does, i'd like to white out a bunch of text on a very primative form.

If the check exists, conditionally format
If it doesn't exist, don't do anything.

Basically, i think i wanna put code in cell Z50000 to check the control, but am clueless as to how to do it. And do the same thing with other controls as well.

Any help would be appreciated.

Chris in Tokyo
(somebody stop the N. Korea leaders.... they're gonna kill us all).
 
Upvote 0
Hello

I know this post is from a long time ago but it is similar to my problem adn I was hopeing you migth be able to help.

I am trying to use check boxes and write the macros for them.
I have a list of items in a column on one sheet and I want to insert check boxes into the column next to the list.
I then want to write a code which says: If the check box in column B is checked (true) then the word in column A is inserted into a different sheet.

I think it must be straight forward but am struggling!
 
Upvote 0
I did this:

Private Sub OpenQA_Click()
If ActiveSheet.OpenQA.Value = True Then
Shell "WINWORD.exe G:\Shared\Oscar Salinas\Metales\New Folder\QA.doc", vbMaximizedFocus
Else
MsgBox "Unchecked. To continue, please check"
End If
End Sub

OpenQA is the name of my checkbox; I'am trying to open a file when the checkbox is checked, I think could be with an if, and I could do that with this command but when the file is attempting to open, an error message is shown with the message that "word experience an error trying to open the file: suggestion: check file permission, free memorie", so what do you think is the problem with this
 
Upvote 0
I have a similar problem, however I can't seem to resolve it using the suggestions posted above. Right now my code is as follows:

Code:
Private Sub longweekend1_click()

   If longweekend.Value = True Then
      MsgBox "Remember to Set date 3 days back"
   Else
      Worksheets("main").Activate
   End If
End Sub

When I try running this it stops at the if statement and give me error 424: Object required. Any help would be appreciated. Thanks!
 
Upvote 0
The function signature suggests that it should be

Code:
   If longweekend[COLOR=red][B]1[/B][/COLOR].Value = True Then

Using Option Explicit eliminates that kind of problem.
 
Upvote 0
Andrew's code above used to work fine in Excel 2003. I was working on an answer for a friend and it would not work tonight.

Starting in Excel 2007, it would have to be changed to:
If ActiveSheet.Shapes("Check Box 20").ControlFormat.Value = xlOn Then

Bill
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,306
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top