Solved

Sort data in excel spreadsheet

Posted on 2007-04-02
6
927 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:Aiysha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 29

Expert Comment

by:Badotz
ID: 18837256
Do you get an error of some kind?
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 18837261
HI

As a bit of a newcomer myself I am not certain, but inserting a string for a cell address to replace text1.text fails for me so I assume it represents your problem.

Removing the superfluous optplot from the second line, (Selection.Sort Key1:=optplot.Cells(2, 10), Order1:=xlAscending, Header:=xlGuess etc.) results in a good sort so is this the problem?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 18837721
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.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 18851445
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
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question