I have the following macro that will sort range C3:H298 by column D -
Range("c3:h298").Select
Selection.Sort Key1:=Range("D
"),Order1:=xlDescending, header:=xlNo, _OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
However, if someone adds a row, I don't want to change the range selection in the macro everytime. So I added a formula in cell A1 that will calculate the total rows. I want Cell A1 to now be in the range selection, but I'm not sure how to compile that. Here is what I tried -
Dim CELLA1
CELLA1 = Range("A1").Value
Range("c3:hCELLA1").Select
Selection.Sort Key1:=Range("D
"), Order1:=xlDescending, header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Any help would be great. TIA.
Range("c3:h298").Select
Selection.Sort Key1:=Range("D
However, if someone adds a row, I don't want to change the range selection in the macro everytime. So I added a formula in cell A1 that will calculate the total rows. I want Cell A1 to now be in the range selection, but I'm not sure how to compile that. Here is what I tried -
Dim CELLA1
CELLA1 = Range("A1").Value
Range("c3:hCELLA1").Select
Selection.Sort Key1:=Range("D
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Any help would be great. TIA.