Error 1004 (Sort method of Range class failed)

LearningEX

Board Regular
Joined
Mar 13, 2015
Messages
208
Hi all

i keep getting this error and when i run F8 it skips this part of the code and goes straight to error

Code:
.Range("s9:s10000").Sort Key1:=.Range("s9"), Order1:=xlAscending, Header:=xlNoEnd With
'reset error
   On Error GoTo 0
   Exit Sub
'if error occurs then show me exactly where the error occurs
Sortit_Error:

and this is the whole code

Code:
Sub Sortit_123()'error handler
   On Error GoTo Sortit_Error
'sort the phone list
With Sheet7
.Range("B9:r10000").Sort Key1:=.Range("r9"), Order1:=xlAscending, Header:=xlNo
'sort the index numbers
.Range("s9:s10000").Sort Key1:=.Range("s9"), Order1:=xlAscending, Header:=xlNo
End With
'reset error
   On Error GoTo 0
   Exit Sub
'if error occurs then show me exactly where the error occurs
Sortit_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Sortit of Module Sortit_123"
End Sub

Can anyone help please
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Sorry, that doesn't make an sense to me. Remember that you can see your worksheet but we can't. What happens exactly if you perform those sort actions through the user interface?
 
Upvote 0
Sorry, that doesn't make an sense to me. Remember that you can see your worksheet but we can't. What happens exactly if you perform those sort actions through the user interface?

here is my sheet.

if you want to add a new entry open Developer and from the forms select Agency Daily Input and from the dates pick a date between the dates on the worksheet, when done select from drop down lists and the enter a start time and end time then hit add shift.

when done go back and look at the entry it should be in between the start and end dates then take a look at the Pay rate col and you will notice that they do not relate to the correct row.


https://www.dropbox.com/s/z9qkgxe2x7erg5n/for forum.xlsm?dl=0
 
Upvote 0
In the formulas in column T on sheet Agency_Daily_Input you need to remove all references to that sheet. For example Agency_Daily_Input!D9 would become simply D9. For an explanation see:

Daily Dose of Excel » Blog Archive » Sorting Formulas with Sheet Names

thank you sir, once again you have sup parsed yourself as a great teacher yet again and i just did not realize that referring to the sheet like that would cause me so much of a head ache

thank you again sir
 
Upvote 0

Forum statistics

Threads
1,214,859
Messages
6,121,963
Members
449,059
Latest member
oculus

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