Aiysha
asked on
Sort data in excel spreadsheet
How can I sort data in Excel spreadsheet through VB 6.0. I have the following code but it fails to sort the data.
optplot.Range(Cells(2, 8), Cells(Val(Me.Text1.Text) + 1, 10)).Select
optplot.Selection.Sort Key1:=optplot.Cells(2, 10), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom , DataOption1:=xlSortNormal
oXL.DisplayAlerts = False
Than you for your help in advance.
optplot.Range(Cells(2, 8), Cells(Val(Me.Text1.Text) + 1, 10)).Select
optplot.Selection.Sort Key1:=optplot.Cells(2, 10), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
oXL.DisplayAlerts = False
Than you for your help in advance.
Do you get an error of some kind?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Looks like I cut the wrong bit!!!
To be clear I suspect the line should be :
Selection.Sort Key1:=optplot.Cells(2, 10), Order1:=xlAscending, Header:=xlGuess etc.
To be clear I suspect the line should be :
Selection.Sort Key1:=optplot.Cells(2, 10), Order1:=xlAscending, Header:=xlGuess etc.
Try this:
With optplot
.Range(.Cells(2, 8), .Cells(Val(Me.Text1.Text) + 1, 10)).Select
.Selection.Sort Key1:=.Cells(2, 10), Order1:=xlAscending, OrderCustom:=1
End With
oXL.DisplayAlerts = False
But in general, we need to see more of your code. You may not be connecting the Excel sheet at all.
Leon
With optplot
.Range(.Cells(2, 8), .Cells(Val(Me.Text1.Text) + 1, 10)).Select
.Selection.Sort Key1:=.Cells(2, 10), Order1:=xlAscending, OrderCustom:=1
End With
oXL.DisplayAlerts = False
But in general, we need to see more of your code. You may not be connecting the Excel sheet at all.
Leon