So, I'm trying to delete any rows that have a duplicate in column C. This is a column of 700 records, however this value depends on different data, so I implemented the "LastRow" function. Here is my code:
Public Function LastRowInCRC() As Long
Dim wsCRC As Worksheet
Set wsCRC = Worksheets("CRC")
With wsCRC
LastRowInCRC = .Cells(.Rows.Count, "C").End(xlUp).Row
End With
End Function
Sub DeleteDupRowsCRC()
Dim wsCRC As Worksheet
Set wsCRC = Worksheets("CRC")
Dim lrowcrc As Long
lrowcrc = CRC.LastRowInCRC
'Debug.Print "C8:C" & lrowcrc
With wsCRC
.Range("C8:C" & lrowcrc).RemoveDuplicates Columns:=Array(3)
End With
End Sub
I get an "application-specific or object-dependent" error in the following line during step-by-step debugging:
.Range("C8:C" & lrowcrc).RemoveDuplicates Columns:=Array(3)
Any ideas what is going wrong? I call "C8: C" and lrowcrc in the nearest window that is commented out and it gives me the correct range values, so I don’t think the problem is this, but I can’t find what is wrong ... any help is greatly appreciated .
source
share