所以我試圖刪除C列中有重複的行。這是大約700條記錄的列,但是這個值隨使用的不同數據而異,因此我實現了一個「LastRow」功能。這裏是我的代碼:VBA Excel刪除重複行
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
我得到的「應用程序定義或對象定義的」在下面的行,當我一步一步地調試錯誤:
.Range("C8:C" & lrowcrc).RemoveDuplicates Columns:=Array(3)
任何想法什麼問題呢?我將「C8:C」& lrowcrc稱爲即時窗口,它被註釋掉了,它給了我正確的範圍值,所以我不認爲問題在那,但我找不到什麼錯誤......任何幫助都很大讚賞。