Hi
I have the below code but realise believe it is sorting only one column which means the other columns will be out of sync?
Here's a recorded macro that will sort the whole table based on column B:
I'm happy to replace with the recorded code however unsure what the 'resize' piece is doing from the 1st piece of code and whether I can include it in the new?
I should mention that I have a a totals row!
advice appreciated!
I have the below code but realise believe it is sorting only one column which means the other columns will be out of sync?
Code:
With ActiveWorkbook.Worksheets("Tech FootPrint")
lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=.Range("B5").Resize(lastrow - 3), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.Sort.SetRange .Range("B5").Resize(lastrow - 3)
.Sort.Header = xlNo
.Sort.MatchCase = False
.Sort.Orientation = xlTopToBottom
.Sort.SortMethod = xlPinYin
.Sort.Apply
End With
Here's a recorded macro that will sort the whole table based on column B:
Code:
Range("Table16[[#Headers],[Client]]").Select ActiveWorkbook.Worksheets("Tech FootPrint").ListObjects("Table16").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Tech FootPrint").ListObjects("Table16").Sort. _
SortFields.Add Key:=Range("Table16[Client]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Tech FootPrint").ListObjects("Table16").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
I'm happy to replace with the recorded code however unsure what the 'resize' piece is doing from the 1st piece of code and whether I can include it in the new?
Code:
Range("B5").Resize(lastrow - 3), _
I should mention that I have a a totals row!
advice appreciated!
Last edited: