Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A VBA code that clicks a checkbox

Having some difficulty with VBA code. Any help is appreciated...
What I am trying to do is to have an "IF" command that would
CHECK a checkbox in excel if a certain cell has a certain text in it,
i.e.

Sub Click_Me()
If "A12" = "Mortgage" Then CheckBox10_Click = True
End Sub

What am I doing wrong?

Thank you very much in advance.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default A VBA code that clicks a checkbox

Try this

Sub Click_Me()
a = CheckBox10
If ActiveSheet.Range("A130").Value = "Mortgage" Then
ActiveSheet.CheckBox10.Value = True
Else
ActiveSheet.CheckBox10.Value = False

End If

End Sub

You can see the differences. Basically each cell has to
have a value assigned.

BOL

DavidC
-----Original Message-----
Having some difficulty with VBA code. Any help is

appreciated...
What I am trying to do is to have an "IF" command that

would
CHECK a checkbox in excel if a certain cell has a certain

text in it,
i.e.

Sub Click_Me()
If "A12" = "Mortgage" Then CheckBox10_Click = True
End Sub

What am I doing wrong?

Thank you very much in advance.


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default A VBA code that clicks a checkbox

As for what you are doing wrong, CheckBox10_Click is an event handler (a
procedure that executes when an event occurs). It is not something you can
assign a value to. If you wanted your code to execute the same code that a
mouse click would execute, you can call the event handler like any procedure
(but this would NOT change the state of the checkbox, as an actual mouse
click would).

Sub Click_Me()
If "A12" = "Mortgage" Then CheckBox10_Click
End Sub


"nevaspb " wrote in message
...
Having some difficulty with VBA code. Any help is appreciated...
What I am trying to do is to have an "IF" command that would
CHECK a checkbox in excel if a certain cell has a certain text in it,
i.e.

Sub Click_Me()
If "A12" = "Mortgage" Then CheckBox10_Click = True
End Sub

What am I doing wrong?

Thank you very much in advance.


---
Message posted from http://www.ExcelForum.com/



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
Simple Checkbox Message Code nemadrias Excel Discussion (Misc queries) 10 June 21st 06 08:59 PM
controlling another application via VBA code in Excell & sending keystrokes & mouse clicks Zaidan Excel Programming 0 June 6th 04 09:06 PM
How to Check a checkbox on spreadsheet from VB code Harinath Excel Programming 2 April 8th 04 09:51 AM
Checkbox Code Edwin Tam[_2_] Excel Programming 0 January 14th 04 02:26 AM
testing the state of a checkbox in vba code Paul James[_3_] Excel Programming 10 December 5th 03 07:55 PM


All times are GMT +1. The time now is 01:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"