我试图在 excel 上运行宏来删除每列中的重复值而不影响其他列的值,但我收到以下错误
Compile Time error: Sub or function not defined
下面是我的宏
Sub RemoveDups()
Dim wrkSht As Worksheet
Dim lLastCol As Long
Dim lLastRow As Long
Dim i As Long
'Work through each sheet in the workbook.
For Each wrkSht In ThisWorkbook.Worksheets
'Find the last column on the sheet.
lLastCol = LastCell(wrkSht).Column
'Work through each column on the sheet.
For i = 1 To lLastCol
'Find the last row for each column.
lLastRow = LastCell(wrkSht, i).Row
'Remove the duplicates.
With wrkSht
.Range(.Cells(1, i), .Cells(lLastRow, i)).RemoveDuplicates
Columns:=1, Header:=xlNo
End With
Next i
Next wrkSht
End Sub
有人可以帮我吗?谢谢
答案1
LastCell(wrkSht).
它无法在您的 VBA 项目中找到 LastCell 函数。