VBA Excel Removing duplicate rows

Viewed 881

So I'm trying to remove any rows that have a duplicate in column C. This is a column of about 700 records however this value varies with different data used hence I've implemented a "LastRow" function. Here's 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 the "application-defined or object-defined" error at the following line when I step by step debug:

.Range("C8:C" & lrowcrc).RemoveDuplicates Columns:=Array(3)

Any ideas whats going wrong? I call the "C8:C" & lrowcrc to the immediate window which is commented out, and it gives me the correct range values so I don't think the issue is in that but I cannot find whats wrong... any help greatly appreciated.

2 Answers
Related