I am using the code that I was helped with in this previous question: (VBA Excel find and replace WITHOUT replacing items already replaced)
I have the following code that I use to replace items in a column: Sub Replace_Once() Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:A" & LastRow).Interior.ColorIndex = xlNone
For Each Cel In Range("B1:B" & LastRow)
For Each C In Range("A1:A" & LastRow)
If C.Value = Cel.Value And C.Interior.Color <> RGB(200, 200, 200) Then
C.Interior.Color = RGB(200, 200, 200)
C.Value = Cel.Offset(0, 1).Value
End If
Next
Next
Which works fine for small files, but when column A approaches 3800 in length and B and C are about 280 Excel crashes and I get the following error:
Run-time error '-2147417848 (800810108)':
Method 'Color' of object "Interior' failed
Any ideas why this could be happening?
EDIT: Just to clarify the error seems to happen in the line
If C.Value = Cel.Value And C.Interior.Color = RGB(200, 200, 200) Then