xlLeftToRight sort not reordering column headers during sort.
Hello. Been struggling with an issue for days now. I have a range of data that needs to be re-ordered from left to right descending and although I have the values in the range sorting, the corresponding headers are not sorting.
An example would be:
COL A B C
Row1 Abe Ben Cat
Row2 1 2 3
Row3 1 2 3
Row4 1 2 3
Row5-sum 3 6 9
And my sort is like this:
Range("A1:C5").Select
ActiveWorkbook.Worksheets("(2) Data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("(2) Data").Sort.SortFields.Add Key:=Range( _
("A1:C5"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= xlSortNormal
With ActiveWorkbook.Worksheets("(2) Data").Sort
.SetRange Range("A1:C5")
.Header = xlGuess
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
I have tried xlGuess, xlYes, and xlNo and each time the result is the same; my data is sorted correctly, but the columns are not. An example after sort would be:
COL A B C
Row1 Ben Abe Cat
Row2 3 2 1
Row3 3 2 1
Row4 3 2 1
Row5-sum 9 6 3
I can provide real data and real code, just thought this simple example would work, just let me know if I should post real data and code (no confidential info in data).
Thanks very much,
Dan
Recent comments
5 years 42 weeks ago
6 years 28 weeks ago
6 years 40 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 49 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago