1

I am new to VBA. Currently I am trying to remove duplicate rows from a non-header spreadsheet where, lastColumn is last column of worksheet. lastRow is last row of worksheet.

It is working fine for:

ActiveSheet.Range(Cells(1,1), Cells (lastRow,lastColumn)). RemoveDuplicates(Columns:=Array(1,2,3), Headers:=xlNo)
  • But it will work only for 3 columns each time.

I want to remove duplicate rows from Excel worksheet by making Array dynamically. Trying the same using Application.Evaluate function to create a sequence of Array from first to last column of spreadsheet.

myArray=Evaluate ("Row(1:" & lastColumn & ")")
ActiveSheet.Range(Cells(1,1), Cells (lastRow,lastColumn)). RemoveDuplicates(Columns:=myArray, Headers:=xlNo)

But getting

"invalid procedure call or argument" error.

Is there any possible way to do it for a header/ non-header spreadsheet?

BigBen
  • 46,229
  • 7
  • 24
  • 40
The Flash
  • 33
  • 5

0 Answers0