I am trying to sort a page in excel. The trick is I want it to sort a range of cells that might change as new rows are added by the user. I am working off of the macro excel wrote when I started sorting.
What I want to do is set the first cell of the range into a variable as well as the last cell of the range which is the one which will change. I am also using an offset to determine what that cell is.
I can't figure out how to make an acceptable variable that refers to a cell.
Secondly, I can seem to get it to except the range using one variable to another.
ActiveWindow.SmallScroll Down:=-3
Dim cell_first As Range
Dim cell_last As Range
cell_first = Range("B5")
cell_last = Range("sortend").Offset(-1, 0)
Range("cell_first":"cell_last").Select
Selection.Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
What I want to do is set the first cell of the range into a variable as well as the last cell of the range which is the one which will change. I am also using an offset to determine what that cell is.
I can't figure out how to make an acceptable variable that refers to a cell.
Secondly, I can seem to get it to except the range using one variable to another.
ActiveWindow.SmallScroll Down:=-3
Dim cell_first As Range
Dim cell_last As Range
cell_first = Range("B5")
cell_last = Range("sortend").Offset(-1, 0)
Range("cell_first":"cell_last").Select
Selection.Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal