Auto Sort Macro Error, Office 365

bobaroski2121

New Member
Joined
Jun 14, 2013
Messages
13
I have an auto sort macro that arranges entries based on the date placed in the column.

Sub Sort_Macro()
Range("A25:O2000").Sort Key1:=Range("A26"), Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End Sub

It seems random, but occasionally I will receive an error:

Run-time error 1004: Sort method of Range class failed.

I cant seem to figure out hwo to debug. any thoughts?
 
It might be better if you could post the spreadsheet here or on the internet where someone could look at it. The circumstances of when it happens might also be useful. One thing that might cause a problem is if it is run while the sheet that it was made for is not active or something along those lines.
Since it works most of the time it might not be a problem with the code, but some other circumstances.
 
Upvote 0
I could post the spreadsheet, but I was wondering if someone knew what the error specifically meant. When looking online, i was unable to find what part of the macro the error refers to other than the generic sort function. It happens when I am adding a new entry to the spreadsheet, i.e. one column is 'date', the next is 'entry type', the next 'details'. After typing in the date, the error will appear. I will start uploading the spreadsheet now
 
Upvote 0
It says I need permission to access it. I clicked the appropriate button you should be getting a request from google to let me access it.
 
Upvote 0
just changed the permission settings. the tab in question is 'Remington Park (Quarter Horse)'. I am trying to add the date for the newest entries at the bottom
 
Upvote 0
I downloaded your sheet and ran the macro and got the error. It appears the sheet is protected, which might be the problem. I obviously don't have your password, but you might see if it is a simple as this. I know I have run into similar problems and they were caused by the sheet being protected.
 
Upvote 0
I tried that but the thing that seems odd is that the other sheets are protected (theyre all protected with the same macro) and yet I dont seem to get the error
 
Upvote 0
Check what is protected on the sheet. I just looked at another spreadsheet I have and one of the protection options is sort. Make sure that option is checked for that sheet. When I right click that cell on that sheet sort is grayed out, but on another sheet as you say sort is not grayed out and therefore leads me to believe this is your problem. At least unlock the sheet and try it that way and check the protection options that are selected for that sheet.
 
Upvote 0
That did it. It seems when I put together the protect all macro, something (or someone in the office) also placed a protect sheet for that specific sheet. I had the same issue on two other sheets and that solved it. Thanks for your help!!!
 
Upvote 0

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