vba sort routine

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,583
Office Version
  1. 365
Platform
  1. Windows
hello,

I am trying to write a routine to sort a range into descending order but get an error saying that "Order" is not correct syntax. can anyone tell me why pls ? thank you.

kind regards
Kaps

VBA Code:
Public Sub sort_data(sheets As String)
Dim last_output_row As Integer
Dim output_range As Range


last_output_row = output_wb.sheets(sheets).Cells.SpecialCells(xlCellTypeLastCell).Row
Set output_range = output_wb.sheets(sheets).Range("A2:g" & last_output_row)

output_range.Sort key1:=output_wb.sheets(sheets).Range("d2"), Order:=xlDescending, Header:=xlYes


End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
It should be Order1 not Order.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,597
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top