See the modifications made to your Main sheet in the attached workbook.
The following macro will sort you columns:
'SORT the columns
Last_row = Cells(Rows.Count, 5).End(xlUp).Row 'Row of last formula in column 5 is the number of rows to sort
Range("F1", Cells(1, Columns.Count).End(xlToLeft)).EntireColumn.Select
ActiveWorkbook.Worksheets("Main").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Main").Sort.SortFields.Add Key:=Range("F1", Cells(1, Columns.Count).End(xlToLeft)), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Main").Sort
.SetRange Range("F1", Cells(Last_row, Cells(1, Columns.Count).End(xlToLeft).Column))
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
Be sure to check carefully all of your formulas and other VBA codes as the added row might have impacted them.
Bookmarks