Compile Error on Sorting

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
83
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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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