VBS:删除excel中的重复行



我有一个脚本,可以合并XLS文件,删除中间头,我还想删除重复的行。

这是有效的(如果第1列到第7列相同,则删除该行(:

objSheet.UsedRange.RemoveDuplicates array(1,2,3,4,5,6,7)

但我想推广并传递给这个数组函数,表的列数,但不知道如何。

由于我无法将数组传递给数组函数,我使用execute方法来执行:

' create the string with cols and commas
for col=1 to lastcolumn
colnumbers = colnumbers & col & ","
Next
' delete final comma
colsComma = Left(colnumbers, Len(colnumBers) - 1)
' mount execute line
rmdups = "objSheetDst.UsedRange.RemoveDuplicates array(" & colsComma & ")"
execute(rmdups)

最新更新