I am writing VBA code that includes the removal of duplicate records. Using Developer, I determined that the instruction for removing duplicated records from the original data set that has 1211 records, starting at A1, aand which can reach column Y, are:

Columns("A:Y").Select
ActiveSheet.Range("$A$1:$Y$1211").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), Header:=xlNo

It is quite possible that in other data sets, the last column may go beyond column Y, i.e., beyond the 25th column. It is easy to vary the range "$A$1:$Y$1211" to what's appropriate, but how do I make the Array(1,...,25) dynamic?

Can anybody help?