robcunliffe
Technical User
Hello
I am using office XP writting some VB for excel.
I have a fairly simple command that will sort data.
The user will click on a button to bring up a userform. The userform has a combo box. The combo box entries are cells (i.e. a5 , g5 etc) The user selects a cell they wish to sort on and click go.
Within the sub the datasort commands look like this (generated from a macro)
Range("A5:N5000").Select
Selection.Sort Key1:=Range(Cbosortby.Value), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A6").Select
I ahve basically substituted the key1:=range()
for the cell the user selects in the combo box.
However i would like the combo box to contain entries like "UserID" or "Date" But i do not know what to put in the range bracket (above) so that it will sort the column.
For example the user selects "Date" from the combo box and the data is sorted for column A.
Can anyone help
Many Thanks
Rob Cunliffe
I am using office XP writting some VB for excel.
I have a fairly simple command that will sort data.
The user will click on a button to bring up a userform. The userform has a combo box. The combo box entries are cells (i.e. a5 , g5 etc) The user selects a cell they wish to sort on and click go.
Within the sub the datasort commands look like this (generated from a macro)
Range("A5:N5000").Select
Selection.Sort Key1:=Range(Cbosortby.Value), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A6").Select
I ahve basically substituted the key1:=range()
for the cell the user selects in the combo box.
However i would like the combo box to contain entries like "UserID" or "Date" But i do not know what to put in the range bracket (above) so that it will sort the column.
For example the user selects "Date" from the combo box and the data is sorted for column A.
Can anyone help
Many Thanks
Rob Cunliffe