PDA

View Full Version : Copy Highlighted Cell to Another Worksheet



spencerp237
03-23-2017, 09:04 AM
I have tried doing this:



Sub MoveHighlightedErrors()


Dim rowIndex As Long


rowIndex = 3




With Sheets("Sheet1")


For i = 4 To .Range("E4").CurrentRegion.Rows.Count
If .Cells(i, 9).Interior.Color = 65535 And .Cells(i, 11).Interior.Color = 65535 Then
Sheets("Sheet1").Range(.Cells(i, 5), .Cells(i, 11)).Copy Destination:=Sheets("Sheet2").Rows(rowIndex)
rowIndex = rowIndex + 1
End If
Next i


End With


End Sub


Which unfortunately doesn't work. I'm not sure how to properly read a highlighted cell.

Columns I and K could be highlighted. If they are both highlighted, I want to copy columns E:K for that row, and copy it to Sheet2 starting on row 3.


*Edit
The highlighted cells are conditionally formatted

JBeaucaire
03-23-2017, 10:26 AM
Color isn't data. Typically you use the same CF logic you used to color the cell to also inform your macro. So if your CF formula is looking for values < 100, then your macro would do the same thing, etc.