Can I use a variable as a sort key in VB?
Hi,
I am trying to write a piece of code which will present users with an input
box (asking for a number) which will then select the current range and sort
it using the variable defined by the input box. How would I use the numeric
variable as the key to sorting my data.
Example:
mynumber = InputBox("Please enter the column number that you want the data
splitting by")
Range("A1").Select
ActiveCell.CurrentRegion.Select
Selection.Sort Key1:=mynumber, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
The problem must be around my storing a number as the variable but the sort
command would appear to want a string???
Please help...
|