Excel VBA – RemoveDuplicates方法不适用于Mac

我有下面的一段代码,通过查看两列(列3和5)来从工作表中删除重复项。

lRow = .Cells(Rows.Count, "A").End(xlUp).Row '.Range("A1:BR" & lRow).RemoveDuplicates Columns:=Array(3, 5), Header:=xlYes .Range("$A$1:$BR$" & lRow).RemoveDuplicates Columns:=Array(3, 5), Header:=xlYes 

它在Windows中工作正常,但不幸的是没有在Mac上。

任何人都可以build议我在这里需要改变什么?

这段代码将创build一个唯一值列表并复制到另一个单元格中。 所以创build独特的列表。

您必须指定列表的起始位置以及要复制到的位置。 你可以通过改变fromCell和toCellvariables来做到这一点。 我希望这有帮助。

Sub uniqueList()

 fromCell = "A1" toCell = "B1" fromColumn = Mid(fromCell, 1, 1) 'This will resolve to A toColumn = Mid(toCell, 1, 1) 'This will resolve to B fromRow = Mid(fromCell, 2) 'This will resolve to 1 toRow = Mid(toCell, 2) 'This will resolve to 1 Dim cl As Range, UniqueValues As New Collection, uValue As Variant Application.Volatile numRows = Range(fromCell).End(xlDown).Row On Error Resume Next For Each cl In Range(fromCell & ":" & fromColumn & numRows) UniqueValues.Add cl.Value, CStr(cl.Value) Next cl y = toRow - 1 For Each uValue In UniqueValues y = y + 1 Range(toColumn & y) = uValue Next uValue 

结束小组