Thanks you two. Great help. I'm fairly new to this
VB stuff so I am
interested in why there are differences in the way you both handled that
problem. Bob - What does the CLng bit do that wasn't in the other response.
For the record, I used the version without this in as it looked simpler :-)
"Bob Phillips" wrote:
Dim mynumber
mynumber = InputBox("Please enter the column number that you want the data
splitting by")
Range("A1").Select
ActiveCell.CurrentRegion.Select
Selection.Sort Key1:=Selection.Cells(1, CLng(mynumber)),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Pablo Bellissimo" <Pablo wrote in
message ...
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...