![]() |
Check Box Code Does Not Work
I have had four suggestions on how to make this work and so far none will work. Now the True Statement has something wrong.
Can anyone help? Private Sub CheckBox1_Click() With CheckBox1 If .Value = True Then ActiveSheet.Range("A2").Value = Range("Sheet2!$B$4").Value Else If .Value = False Then ActiveSheet.Range("A2") = "" End If End If End With End Sub Thank You very much |
Check Box Code Does Not Work
It worked when I did it like this:
Private Sub CheckBox1_Click() With CheckBox1 If .Value = True Then ActiveSheet.Cells(2, 1).Value = Worksheets(2).Cells(4, 2).Value ElseIf .Value = False Then ActiveSheet.Range("A2") = "" End If End With End Sub - Pikus --- Message posted from http://www.ExcelForum.com/ |
Check Box Code Does Not Work
Man, attitude. we're trying to help.
First, the code should be Private Sub CheckBox1_Click() With CheckBox1 If .Value = True Then ActiveSheet.Range("A2").Value = _ Worksheets("Sheet2").Range("$B$4").Value Else ActiveSheet.Range("A2") = "" End If End With End Sub Next. This is the click event for the checkbox, so be sure that its on the worksheet's code page...the sheet on which you have the checkbox...right click the sheet tab & select view code Finally, rather than moan about an error, tell us exactly what the error is and on which line. We are here to help, and this isn't a difficult process that you're stuck on. Please keep us posted with your progress Patrrick Molloy Microsoft Excel MVP -----Original Message----- I have had four suggestions on how to make this work and so far none will work. Now the True Statement has something wrong. Can anyone help? Private Sub CheckBox1_Click() With CheckBox1 If .Value = True Then ActiveSheet.Range("A2").Value = _ Worksheets("Sheet2").Range("$B$4").Value Else If .Value = False Then ActiveSheet.Range("A2") = "" End If End If End With End Sub Thank You very much . |
Check Box Code Does Not Work
Pikus, Thank you so much!!! Works Great!!!! Bob *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Check Box Code Does Not Work
Patrick Molly, Sorry your code does not work. Boy did you get up on the wrong side of the bed. Or maybe you haven't gone to bed Yet. Thank you for trying, Bob *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Check Box Code Does Not Work
Any time yo!
What were they talking about attitude?!? I missed something... - Piku -- Message posted from http://www.ExcelForum.com |
Check Box Code Does Not Work
pikus,
Again thanks for your help. I have another problem you may be able to help with. Using the code below I cannot figure out how to choose a range of cells. Private Sub CheckBox2_Click() With CheckBox2 If .Value = True Then Worksheets(2).Cells(9, 1).Value = ActiveSheet.Cells(9,1).Value Else Worksheets(2).Cells(9, 1).Value = "" End If End With End Sub Another words how do I choose: Worksheets(2).Cells(A9:D9).Value = This will not work. I have also tried Range(Cells(). Thank you for your help. Bob *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Check Box Code Does Not Work
Worksheets(2).Range("A9:D9").Value = _
Activesheet.Range("A9:D9").Value Else Worksheets(2).Range("A9:D9").ClearContents -- Regards, Tom Ogilvy Bob Ciepiela wrote in message ... pikus, Again thanks for your help. I have another problem you may be able to help with. Using the code below I cannot figure out how to choose a range of cells. Private Sub CheckBox2_Click() With CheckBox2 If .Value = True Then Worksheets(2).Cells(9, 1).Value = ActiveSheet.Cells(9,1).Value Else Worksheets(2).Cells(9, 1).Value = "" End If End With End Sub Another words how do I choose: Worksheets(2).Cells(A9:D9).Value = This will not work. I have also tried Range(Cells(). Thank you for your help. Bob *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Check Box Code Does Not Work
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Check Box Code Does Not Work
Tom,
Thank you for your reply. Below is the code I am now using per row, per check box. How can it be written to do the same thing 10 to 20 times without writing the same code per row for each check box 10 to 20 times? Using a starting check bo number and ending with a higher check box number. Private Sub CheckBox2_Click() With CheckBox2 If .Value = True Then Worksheets(2).Range("A9:C9").Value = ActiveSheet.Range("A9:C9").Value Else Worksheets(2).Range("A9:C9").Value = "" End If End With End Sub Thanks again for your help Tom. I may have sent this twice by mistake. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Check Box Code Does Not Work
Though as far as I can tell you will need to put some code into each of
your checkboxes, you can minimize it. What I’d recommend is to have the checkbox call a function and pass the relevant info. - Pikus In Sheet1: Private Sub CheckBox1_Click() Call ChBxClick(CheckBox1.Value, _ Worksheets(1).Range("A9:C9"), _ Worksheets(2).Range("A9:C9")) End Sub Then in Module1: Public Sub ChBxClick(chBx As Boolean, rng1 As Range, rng2 As Range) If ChBx = True Then rng2.Value = rng1.Value Else rng2.Value = "" End If End Sub --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 10:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com