copy paste code not working(troubleshoot pls)

P

pswanie

Private Sub CommandButton1_Click()
NewRowCount = 1
Lastrow = Range("N" & Rows.Count).End(xlUp).Row
For RowCount = 1 To Lastrow
If Range("N" & RowCount).Interior.ColorIndex = 8 Then
Range("d" & NewRowCount) = Range("N" & RowCount)
NewRowCount = NewRowCount + 1
End If
Next RowCount

End Sub



i got this string from joel... (thanx) but does not do what i need. in
fact clicking on the command button does nothing.


what i need is to copy all data in the cells with turqoise (8) colour from
column N to colum A.
 
J

Joel

You have column d instead of column A. If you want to preserve the color
than you need to copy the cell rather than equal.

Did you put a break point in the code to make sure the command button was
working?

NewRowCount = 1
Lastrow = Range("N" & Rows.Count).End(xlUp).Row
For RowCount = 1 To Lastrow
If Range("N" & RowCount).Interior.ColorIndex = 8 Then
Range("N" & RowCount).Copy _
Destination:=Range("A" & NewRowCount)
NewRowCount = NewRowCount + 1
End If
Next RowCount
 
P

pswanie

break point i did. not to bright on what that mean yet. so i cant say if
what should hapen did..... can i mail a copy of the workbook to you to
check? Please

Phillip
 
J

Joel

Break point will indicate that the button is working.

send to joel dot warburg at itt dot com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top