Fordraiders
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
vba routine
I have some code that sorts a sheet based another sheets value.
Sheets("Sheet2").Activate
c = Sheets("Sheet2").Range("K1
w = Sheets("Sheet2").Range("L1
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use drop down box
ASKER
Thanks !