469,167 Members | 2,108 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

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 1180
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

Post your reply

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

Similar topics

13 posts views Thread by LL | last post: by
1 post views Thread by Stephen | last post: by
3 posts views Thread by Ed Jay | last post: by
4 posts views Thread by prhodes | last post: by
4 posts views Thread by dancer | last post: by
3 posts views Thread by dancer | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.