473,503 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is VBA Excel not finding checkbox object?

9 New Member
I have added 4 checkboxes to a spreadsheet and want my macro to check the value of each one. When I step through the macro to the If statement below, I get an error message saying that the object is required. I'm new to VBA and not sure if the problem is there or on the Excel side.

If CheckBox1.Value = False Then

I have tried putting the spreadhsheet name in front of the checkbox name

eg - If MAIN.CheckBox1.Value = False Then

but that didn't help. What am I doing wrong??
May 18 '10 #1
4 21359
QVeen72
1,445 Recognized Expert Top Contributor
Try :
Worksheets("Sheet1").CheckBox1.Value
OR
ActiveSheet.Checkboxes("CheckBox1").Checked = False
OR
ActiveSheet.Checkboxes(1).Checked = False
May 19 '10 #2
Guido Geurs
767 Recognized Expert Contributor
I'm using excel 2003 and it's working for me with: (see attachment).

Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2.    If CheckBox1.Value = True Then
  3.       MsgBox ("1")
  4.    ElseIf CheckBox2.Value = True Then
  5.       MsgBox ("2")
  6.    ElseIf CheckBox3.Value = True Then
  7.       MsgBox ("3")
  8.    ElseIf CheckBox4.Value = True Then
  9.       MsgBox ("4")
  10.    Else
  11.       MsgBox ("Select a checkbox !")
  12.    End If
  13. End Sub
  14.  
br,
Attached Files
File Type: zip Why is VBA Excel not finding checkbox object 1.zip (11.6 KB, 497 views)
May 19 '10 #3
rosshughson
9 New Member
Thanks QVeen72. When I included the worksheet name in the format you indicated it worked with no problems.
May 19 '10 #4
rosshughson
9 New Member
@QVeen72
HI. When I specified the worksheet name in the format you specified it worked with no problems. Thanks for your help.
May 19 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1408
by: Curro | last post by:
Hello We've developed a Web Form that uses Excel. We have installed Excel 2000 on Windows 2000. So, we're using Excel 9.0 object library. Now, we want to translate our application to a...
0
1393
by: Dent | last post by:
I am having a problem with a program that I wrote to format an Excel spreadsheet. I wrote the program on a WinXP/Office XP/Visual Studio .NET 2003 computer. I am using late-binding. When I try...
1
1962
by: cybertof | last post by:
Hello, Is there a .net native assembly / object_library to communicate with Excel 2003 ? All articles I have read are all using the Microsoft Excel Object Library which is a COM object, even...
3
7528
by: Ali Tahbaz | last post by:
I'm having trouble iterating through LinkSources in an Excel workbook using C#. I first wrote the below code in VBA to get a quick, correct result, Dim x As Variant For Each x In...
2
15311
by: xhenxhe | last post by:
I don't some Excel automation. I've created a program that opens and Excel template and inputs information to it. It runs great on my machine. When I build and deploy I have a user that keep...
5
6329
by: brooks | last post by:
I have an unbound OLE object on a form: Name: OLEExcelChart OLE Class: Microsoft Excel 2000 Class: Excel.Chart.8 I need to manipulate properties of the chart as well as the underlying data....
1
2225
by: JP | last post by:
I have images within a datalist control. Below is a checkbox control that contains the SQL ID of the image blob. When the page is post back I want to iterate though checkbox collection to get...
1
2008
by: Gultekin Komanli | last post by:
Hi all, When I try to add reference to Excel, I select my project's porperties from the Project menu, on the add reference dialog, tab named COM, there are Excel 11.0 and Excel 5.0 Object...
2
1448
by: yogeshtiwarijbp | last post by:
By using add reference i have included microsoft excel 11.0 object library in asp.net and also included in the namespace using microsoft.office.interop.excel and using system .reflection. But the...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.