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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
It should be Order1 not Order.
 
Upvote 0

Forum statistics

Threads
1,215,403
Messages
6,124,710
Members
449,182
Latest member
mrlanc20

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