How to Select Range based on Variables in Excel VBA?

No replies
User offline. Last seen 2 years 49 weeks ago. Offline
Joined: 06/13/2009
Posts: 6

Hi, I'm very new to programming...

Right now I'm writing Excel macros that will sort data in accending order.

From the macro recording I have:
Range("A1:T19").Select
Range("T19").Activate
Selection.sort Key1:=Range("T19"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

However, I want to unselect the rows if the value for first cell of that row (Cells(x,1)) is empty. So that only the row where Range("Ax")<>Empty are selected.

I tried using variables and if... then commands but none worked. Any ideas? Thanks in advance!! =)