New here and to macros in Excel. Would really appreciate your help with a sorting macro!
I have projects listed out in rows with various data in columns. I'm trying to create macro buttons that sort the projects & data.
Since I add projects to the group and didn't want to update the macros with the correct cells to sort, I've been trying to use Named Cells.
The projects I add sometimes have to be at the very beginning, very end or somewhere in the middle so I've defined upper and bottom border rows to help define in the macro where the data selection starts and stops. In the macro, I'm hoping to be able to select the entire rows between the border rows in case additional data columns are added in the future.
If I record a macro, this is the code I get;
Row 14 is the entire row below the Upper Border Row = "ProjectDataFirstRow"
Row 149 is the entire row above the Lower Border Row = "ProjectDataLastRow"
I've also named the first cell of the Upper Border Row as "CellSelectionFirst" and the first cell of the Lower Border Row as "CellSelectionLast" if that helps?
I've searched as best I can but haven't found or couldn't figure out how to select entire rows between the border rows or border cells.
Thanks for the help!!
I have projects listed out in rows with various data in columns. I'm trying to create macro buttons that sort the projects & data.
Since I add projects to the group and didn't want to update the macros with the correct cells to sort, I've been trying to use Named Cells.
The projects I add sometimes have to be at the very beginning, very end or somewhere in the middle so I've defined upper and bottom border rows to help define in the macro where the data selection starts and stops. In the macro, I'm hoping to be able to select the entire rows between the border rows in case additional data columns are added in the future.
If I record a macro, this is the code I get;
Sub SortProjectNameA2Z()
Rows("14:149").Select
ActiveWorkbook.Worksheets("OVERALL").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("OVERALL").Sort.SortFields.Add Key:=Range( _
"A14:A149"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("OVERALL").Sort
.SetRange Range("A14:W149")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A11").Select
Application.CutCopyMode = False
End Sub
Row 14 is the entire row below the Upper Border Row = "ProjectDataFirstRow"
Row 149 is the entire row above the Lower Border Row = "ProjectDataLastRow"
I've also named the first cell of the Upper Border Row as "CellSelectionFirst" and the first cell of the Lower Border Row as "CellSelectionLast" if that helps?
I've searched as best I can but haven't found or couldn't figure out how to select entire rows between the border rows or border cells.
Thanks for the help!!