473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

compile error with checkbox sub

Hello all,
I am attempting to add a check box to the form I created in excel. What I want the macro to do is if the checkBox is checked (= true) then I want the information in cell B13 to be inserted into cell F13. If the checkBox is not checked (= false) then I do not want anything to be done.

I am very new at this so I may need to have things explained to me.

Here is what I have now

Expand|Select|Wrap|Line Numbers
  1. Sub CheckBox1_Click()
  2.  
  3. If CheckBox1.Value = True Then
  4.     Cell(F13) = Cell(B13)
  5. Else
  6. 'do nothing
  7. End If
  8.  
  9. End Sub
  10.  
Thanks for the help
Deirdre
Sep 24 '07 #1
3 1332
Dököll
2,364 Expert 2GB
Hello all,
I am attempting to add a check box to the form I created in excel. What I want the macro to do is if the checkBox is checked (= true) then I want the information in cell B13 to be inserted into cell F13. If the checkBox is not checked (= false) then I do not want anything to be done.

I am very new at this so I may need to have things explained to me.

Here is what I have now

Expand|Select|Wrap|Line Numbers
  1. Sub CheckBox1_Click()
  2.  
  3. If CheckBox1.Value = True Then
  4.     Cell(F13) = Cell(B13)
  5. Else
  6. 'do nothing
  7. End If
  8.  
  9. End Sub
  10.  
Thanks for the help
Deirdre
Nice code, what is it not doing, looks okay to me. I'll give it a whirl see what I have...


What if you did this!

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub TransportData_Click() 'make a button called "TransportData"
  3. If CheckBox1.Value = True Then 'your checkbo still remains "CheckBox1"
  4.     Cell(F13) = Cell(B13)
  5. Else
  6. 'do nothing
  7. End If
  8.  
  9. End Sub
  10.  
Though, I wondered if Enabled would not work here:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub TransportData_Click() 'make a button called "TransportData"
  3. If CheckBox1.Enabled = True Then 'your checkbo still remains "CheckBox1"
  4.     Cell(F13) = Cell(B13)
  5. Else
  6. 'do nothing
  7. End If
  8. End Sub
  9.  
In a bit!
Sep 25 '07 #2
never said what version.. snd..

whats wrong with your original code?
Sep 25 '07 #3
Dököll
2,364 Expert 2GB
Nice code, what is it not doing, looks okay to me. I'll give it a whirl see what I have...


What if you did this!

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub TransportData_Click() 'make a button called "TransportData"
  3. If CheckBox1.Value = True Then 'your checkbo still remains "CheckBox1"
  4.     Cell(F13) = Cell(B13)
  5. Else
  6. 'do nothing
  7. End If
  8.  
  9. End Sub
  10.  
Though, I wondered if Enabled would not work here:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub TransportData_Click() 'make a button called "TransportData"
  3. If CheckBox1.Enabled = True Then 'your checkbo still remains "CheckBox1"
  4.     Cell(F13) = Cell(B13)
  5. Else
  6. 'do nothing
  7. End If
  8. End Sub
  9.  
In a bit!
You could also need to add it like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. ActiveSheet.CheckBox1.Value =1
  3.  
  4.  
Perhaps:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub TransportData_Click() 'make a button called "TransportData"
  3. If ActiveSheet.CheckBox1.Value =1 Then 'checkbox "CheckBox1"
  4.     Cell(F13) = Cell(B13)
  5. Else
  6. 'do nothing
  7. End If
  8. End Sub
  9.  
Got side-tracked a bit, but try it. Please stay tuned, you should get some hits form memebers here. In a bit!
Sep 25 '07 #4

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

Similar topics

13
by: LL | last post by:
Hi, How to fix this problem: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error...
1
by: Stephen | last post by:
I have the following asp:checkbox as a row in my datagrid. and im trying to write code on the onCheckedChanged event of it. The code im trying to write is incorrect as im getting build errors....
3
by: Ed Jay | last post by:
When I run the below js, I get the error: "document.form1.elements.checked) is null or not an object" <script type="text/javascript"> function get_menu_value(menu_name) { var mValue = 0; ...
1
by: solomon_13000 | last post by:
connection.asp: <% Sub RunQueryString (pSQL,parms) on error resume next Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &...
4
by: prhodes | last post by:
I am trying to compile using Oxygen 5.1 and am getting this error: E Only xsl:when and xsl:otherwise are allowed here for this code: <xsl:choose> <xsl:when test="da_unit/unit_type_cd='PMREG'...
4
by: dancer | last post by:
I get this error if an item in a radiobutton list is not chosen when filling in a form.. I added a RequiredFieldValidator, but I still get the message. Object reference not set to an instance of...
3
by: dancer | last post by:
I am using Framework 1.1.4322. Who can tell me why I'm getting this error? My code follows Compilation Error Description: An error occurred during the compilation of a resource required to...
6
by: vijeberal | last post by:
Hi all, I am working on a GridView and there exist a Checkbox control .. iplaced another checkbox in header also i have written a javascript for selection of checkboxex fro e.g if you click on...
1
by: shivasusan | last post by:
Hi Friends! Please Help me! How i can solve this error? Please explain me, what is the error and how to solve? Error Type: ADODB.Recordset (0x800A0E7D) The connection cannot be used to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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
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,...

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.