Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following code that I use to sort a range of data.
Public Sub sorter() Range("b3").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Sort Key1:=Range("S3"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub I am trying to rewrite it, so that I can pass two arguments to it, the first argument would be in place of the "b3" in the second line, and the other argument would replace "S3" in the fifth line of the code above. now my code looks like this: Public Sub sorter(RangeStart, SortKey) Range(RangeStart, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Sort Key1:=Range(SortKey), Order1:=xlDescending, _ Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False,Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub and i was using a call to this procedure that looks like this: sorter (b3, s3) but that doesn't work. Can someone tell me what i am doing wrong? I am new at this, and learning on my own so any help is appreciated. Can I pass a literal as an argument to a procedure? Thanks in advance. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Passing a UDF as an argument to a UDF | Excel Discussion (Misc queries) | |||
passing argument problem ?? | Excel Programming | |||
Passing argument to excel | Excel Programming | |||
Passing argument to another Sub | Excel Programming | |||
Passing an argument to a quote | Excel Programming |