Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort

Status
Not open for further replies.

dje71183

Industrial
Dec 23, 2005
17
I am trying to sort in excel using VBA.

My code is

Code:
 Worksheets("Information").Range("N69:R1500").Sort _
    Key1:=Worksheets("Information").Range("R1500"), _
    Key2:=Worksheets("Information").Range("O69")

Problem is that its starts at the N,1500 and moves up to 1499, 1498, and so on. I would like it to start at N,69 then move down to n,70 N,71 and so on.

Any help would be awesome,
Daniel
 
Replies continue below

Recommended for you

Do you mean that you want to switch from ascending order to descending order? If so, use

Code:
Worksheets("Information").Range("N69:R1500").Sort _
    Key1:=Worksheets("Information").Range("R1500"), _
    Order1:=xlDescending, _
    Key2:=Worksheets("Information").Range("O69")

or

Code:
Worksheets("Information").Range("N69:R1500").Sort _
    Key1:=Worksheets("Information").Range("R1500"), _
    Order1:=xlAscending, _
    Key2:=Worksheets("Information").Range("O69")
 
I want my results to start on cell N69. Doestn matter Ascending or Descending..
 
So... are you saying that your unsorted data does not reach to row 1500 and when you sort the data it sorts blank cells to the top?
 
Thats what im trying to say, thank you.
 
I found my problem.

Code:
Worksheets("Information").Range("N69:R1500").Sort _
    Key1:=Worksheets("Information").Range("N69"), _
    Order1:=xlDescending, _
    Key2:=Worksheets("Information").Range("R1")
thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor