I've been searching for hours and can't figure out how to change this coding to do what I need it to.
The first line of the code chooses the columns to select; all columns until there is no value. From there I need to have it sort those columns based on row 1. The problem is that the columns chosen are variable. It could be columns I:N (as shown below) or column G:Z or any other combination. (The code below was recorded if that matters at all.)
Range(ActiveCell, ActiveCell.SpecialCells(xlTextValues)).EntireColumn.Select
ActiveWorkbook.Worksheets("Profit & Loss Standard").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Profit & Loss Standard").Sort.SortFields.Add Key:= _
Range("I1:N1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Profit & Loss Standard").Sort
.SetRange Selection
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
Also, ideally, I would not need to name the sheet as I would like this code to be useable on the current active sheet. Any assistance is very much appreciated.
Thanks in advance,
Kim
Bookmarks