Sorting Syntax using VB

  • Thread starter Thread starter bcap
  • Start date Start date
B

bcap

Hello,

I am a newbie to the use of VB and Excel. I am trying to sort the
range on Sheet 1..order by Company, then by Date most recent date.
Below is what I have but how can I make it acend?

Worksheets("Sheet1").Range("A3:g400").Sort _
Key1:=Worksheets("Sheet1").Range("A1"), _
Key2:=Worksheets("Sheet1").Range("B1")


Any thoughts and help is much appreciated.

Kind Regards,
Ray
 
One thing that as a newbie you might try is to record a macro while you
do what you want manually.

For instance it might look something like

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, _
Key2:=Range("B1") , Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom


You could then modify it for your use:

With Worksheets("Sheet1")
.Range("A3:G400").Sort _
Key1:=.Range("A1"), _
Order1:=xlAscending, _
Key2:=.Range("B1"), _
Order2:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
 
Back
Top