Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

Passing variables to sort a sheet by two columns

Excel 2003
vba routine


I have some code that sorts a sheet based another sheets value.


Sheets("Sheet2").Activate
   c = Sheets("Sheet2").Range("K1").Value
   w = Sheets("Sheet2").Range("L1").Value

If c = "SKU" Then
   
   Sheets("List").Activate
    Cells.Select
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
     
End If

If c = "MFRNUM" Then
   
   Sheets("List").Activate
    Cells.Select
    Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
     
End If


I plan ion adding another cell to the sort..
w = Sheets("Sheet2").Range("L1").Value

so I need the sheet to be sorted by variables  c and w.
So I need the w added to the "If.... Then" statement


Thanks
fordraiders


ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use drop down box
Avatar of Fordraiders

ASKER

Thanks !