Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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! |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Any time yo!
What were they talking about attitude?!? I missed something... - Piku -- Message posted from http://www.ExcelForum.com |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check Box - Macro code | Excel Discussion (Misc queries) | |||
code to check condition for each row | Excel Discussion (Misc queries) | |||
Please check my code!!!! | Excel Discussion (Misc queries) | |||
Check Box Code | Excel Programming | |||
Check my code to use template? | Excel Programming |