I managed to get it working by taking some of your code and adding in a few new letters to reference. I am sure this isn't a great way to do it, but it is working at least. I know that J isn't used anywhere anymore, but I kept it anyways because maybe I will use a similar code for something in the future.
Sub ProgramSetup()
'This Macro will run all of the macros needed for maintenance of the Program Setup worksheet. All macros are contained below in this module
'This macro also makes forms pop up to notify the user that the macro is in progress and again once it finishes.
Range("A1").Select
Application.ScreenUpdating = True
UserForm_ProcessingSort.Show False
Application.ScreenUpdating = False
DoEvents
Application.Wait Now + TimeValue("00:00:01")
Call AutoFit
Call Sort_Markets
Call Sort_Programs
Call Sort_MarketList
Call Activate_TopLeft
Application.ScreenUpdating = True
UserForm_ProcessingSort.Hide
FRM_SortComplete.Show False
End Sub
Sub Sort_Programs()
' This macro will determines the range of columns that have 'Program' data in them and it will sort the
' program data columns horizontally in A-Z order.
j = Cells(Rows.Count, "B").End(xlUp).Row
k = Application.WorksheetFunction.Match("# Program Placeholder", Range("B1:AZZ1"), 0)
l = Range(Cells(1, 2), Cells(300, k)).Address
m = Range(Cells(300, k + 1), Cells(1, Range("b1").End(xlToRight).Column)).Address
n = Cells(1, k + 1).Address
With Range(m)
.Rows.Sort Key1:=.Rows.Range(n), Order1:=xlAscending, Orientation:=xlLeftToRight
End With
End Sub
Sub Sort_Markets()
' This macro will determines the range of columns that have 'Market' data in them and it will sort the
' market data columns horizontally in A-Z order.
j = Cells(Rows.Count, "B").End(xlUp).Row
k = Application.WorksheetFunction.Match("# Program Placeholder", Range("B1:AZZ1"), 0)
l = Range(Cells(1, 2), Cells(300, k)).Address
m = Range(Cells(300, k + 1), Cells(1, Range("b1").End(xlToRight).Column)).Address
With Range(l)
.Rows.Sort Key1:=.Rows.Range("B1"), Order1:=xlAscending, Orientation:=xlLeftToRight
End With
End Sub
Bookmarks