Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
its perhaps easier than you'd think....
there must always be one param, plus optional several more...this code allows up to 3 Option Explicit Sub main() 'demo UserSort "A" UserSort "B", "C", "E" End Sub Sub UserSort(param1 As String, ParamArray addl() As Variant) Select Case UBound(addl, 1) Case -1 Range("A1").CurrentRegion.Sort Range(param1 & "1") Case 0 Range("A1").CurrentRegion.Sort Range(param1 & "1"), , _ Key2:=Range(addl(0) & "1") Case 1 Range("A1").CurrentRegion.Sort Range(param1 & "1"), , _ Key2:=Range(addl(0) & "1"), Key3:=Range(addl(1) & "1") End Select End Sub "Norm" wrote: I'd like to build a macro that does a number of user-specified things to a file. One of them is to sort. The user would specify up to 3 columns to sort. Can an Excel macro "build" the sort parameters? The following sure doesn't work: s = "Key1:=Range(""A2""), Order1:=xlAscending, " & _ "Key2:=Range(""B2""), Order2:=xlAscending, " Range("A1:H6563").Sort s Thanks for the help! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trying to build a If statement | Excel Worksheet Functions | |||
Build whre statement | Excel Programming | |||
How to build effective IF Statement for recurring value in cells....sensitivity analysis | Excel Discussion (Misc queries) | |||
If statement with some sort of lookup function | Excel Worksheet Functions | |||
How to build build a macro that automatically imports | Excel Programming |