Sorting with VBA
Solved
Ecam39
Posted messages
314
Status
Membre
-
Ecam39 -
Ecam39 -
Hello,
I have an Excel table with an undefined (variable) number of rows, and I would like to perform a two-level sort.
The first is in alphabetical order (column B)
The second is also in alphabetical order (column D)
I want to perform this sort on the entire table except for column A, which contains the line numbers. If I include it, I end up with number 15 above number 20, which is not ideal.
Thank you for your responses
Configuration: Windows 7 / Internet Explorer 10.0
I have an Excel table with an undefined (variable) number of rows, and I would like to perform a two-level sort.
The first is in alphabetical order (column B)
The second is also in alphabetical order (column D)
I want to perform this sort on the entire table except for column A, which contains the line numbers. If I include it, I end up with number 15 above number 20, which is not ideal.
Thank you for your responses
Configuration: Windows 7 / Internet Explorer 10.0
3 réponses
Hello,
I feel that the line number in [A:A] is completely unnecessary since it has no relation to the rest of the line.
It should be removed, or what is it for....?
The sorting order is summarized by this line:
Columns("A:X").Sort Key1:=Columns("B"), Order1:=xlAscending, Key2:=Columns("C"), Order2:=xlAscending, Header:=xlGuess
The [Columns("A:X").] refers to the columns of the table, to be adjusted as needed.
--
Regards.
The Penguin
I feel that the line number in [A:A] is completely unnecessary since it has no relation to the rest of the line.
It should be removed, or what is it for....?
The sorting order is summarized by this line:
Columns("A:X").Sort Key1:=Columns("B"), Order1:=xlAscending, Key2:=Columns("C"), Order2:=xlAscending, Header:=xlGuess
The [Columns("A:X").] refers to the columns of the table, to be adjusted as needed.
--
Regards.
The Penguin
Ecam39
The A is the line number but not the Excel line number; it is an accounting number, and it is also not linked to the designations to be sorted.