By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,806 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,806 IT Pros & Developers. It's quick & easy.

compile error with checkbox sub

P: 4
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
Share this Question
Share on Google+
3 Replies


Dököll
Expert 100+
P: 2,364
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

P: 23
never said what version.. snd..

whats wrong with your original code?
Sep 25 '07 #3

Dököll
Expert 100+
P: 2,364
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

Post your reply

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