I cannot get the function below to work. Ideally I would like to create a function that will automatically identify how many used columns are in the sheet then pass that as an array to the delete duplicates. I cannot understand why it is not working. I can confirm that these sheets have headers and multiple rows. I keep on getting error 5 when I try to remove duplicates using the array.
ReDim colary(1 To wbDestination.Sheets(1).Range("XX1").End(xlToLeft).Column)
For i = 1 To UBound(colary)
colary(i) = i
Next i
wbDestination.Sheets(1).Range("$A$1:" & wbDestination.Sheets(1).Range("A1").SpecialCells(xlCellTypeLastCell).Address).RemoveDuplicates Columns:=Evaluate(colary), Header:=xlYes