I'm trying to create a macro that will sort a data range based on a
set of toggles but the macro fails when I make the sort order
(xlAscending or xlDescending) an input. I think the issue is that
the string I'm using as an input comes through with quotation
marks. Any thoughts on how I might get around this problem? I
tried making the variable type a variant and an XlsortOrder but that
didn't fix the problem.
Doesn't work
-----------------
strOrder(i) = "xlDescending"
Selection.Sort Key1:=Range(strKey(1)), Order1:=strOrder(1),
Key2:=Range(strKey(2)), Order2:=strOrder(2), Key3:=Range(strKey(3)),
Order3:=strOrder(3), Header:=xlGuess, OrderCustom:=1,
MatchCase:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=xlSortNormal, DataOption3:=xlSortNormal
Does Work -
------------------
Selection.Sort Key1:=Range(strKey(1)), Order1:=xlDescending,
Key2:=Range(strKey(2)), Order2:=xlAscending, Key3:=Range(strKey(3)),
Order3:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=xlSortNormal, DataOption3:=xlSortNormal