How do I assign a macro for a selected check box in one worksheet and copy the entire row onto another worksheet? What should I do if I have selected some rows and I want all of those selected in the check box appear on the new worksheet? Anybody out there?

Recommended Answers

All 5 Replies

What do you mean by all those selected in the checkbox?

The main problem you have it that when you click on the checkbox it looses focus on what you had selected and places focus on the checkbox so if you ask for selection it errors because there is nothing selected.....

Just to be straight you want to highlight certain rows in say sheet1 then when a check box is clicked it copies all those rows highlighted?

the code you need to mess around with is:

Private Sub CheckBox1_Change()

If CheckBox1.Value = True Then
    '**Code for copying goes here**
End If

End Sub

this code basically says is the checkbox value is equal to ticked then do something, if unticked do nothing.....

I hope this helps!

This may help a bit more!

If CheckBox1.Value = True Then
    Selection.Copy
    Sheets("sheet2").Range("A1").PasteSpecial
End If

if you insert activex checkbox then double click on it to get the code then use the right drop down above to select change and put the above code in the change sub you should be good to go!

Thanks Jamiedude.
Figured out the If then part of it. But the copy pastelink was I got into trouble with. I have the code but it gives me run time error 424. That is where I got into trouble previously too.
Misstrouble

So is this case closed then?

if not paste what you have and i shall see if i can spot whats wrong!

Sub copyrange()
Dim count As Integer
count=2
For a = 1 to 3
If worksheets("Sheet1").Cells(a,4)="Y" Then 
    Worksheets("Sheet1").Cells(a,1).Copy Worksheets("Sheet2").Cells(count,1)
Worksheets("Sheet1").Cells(a,2).Copy Worksheets("Sheet2").Cells(count,2)
Worksheets("Sheet1").Cells(a,3).Copy Worksheets("Sheet2").Cells(count,3)
count=count+1
End If
Next a
End Sub

This is the code may be u could help
This is what this code is supposed to do.
Suppose there are ten rows of ten different items with weight and details in the first sheet when the row that is checked should go onto the next sheet. Logically it should work but cant figure out

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.