Compile Error on Sorting

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
82
I'm trying to insert a line of code at the end of my macro that will sort the list alphabetically. I keep getting this compile error and it points to the word Key1 in my line of code saying that it expects the end of a statement


Code:
 With Sheets("Doc Checklist").Range("C2:C500").Sort Key1:=Range("C2") Order1:=xlAscending, Header:=xlNo

also, should the Range right after Key1 have a Dot before it. I've written both ways thinking that might be giving me the error, but it's not what is causing it.

Thanks in advance :)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Remove the word With from the start of that line
 
Upvote 0
Or

Code:
With Sheets("Doc Checklist")
    [B][COLOR=#ff0000].[/COLOR][/B]Range("C2:C500").Sort Key1:=[B][COLOR=#ff0000].[/COLOR][/B]Range("C2"), Order1:=xlAscending, Header:=xlNo
End With

M.
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

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