ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Run time error '1004' (https://www.excelbanter.com/excel-worksheet-functions/175045-run-time-error-1004-a.html)

aeddave

Run time error '1004'
 
I assigned a recorded macro to an object. When clicked it sorts range
A12:A2500. It works fine until I turn on sheet protection. The range is not
protected, nor is the object.

I receive the error above with "Sort method of range class failed".
Debugging shows below with "Selection....normal" highlighted.

Any help is appreciated

Sub SortByType()
'
' SortByType Macro
' Macro recorded 1/29/2008 by mcgind1
'

'
Range("A12").Select
Application.Goto Reference:="R12C1:R5000C7"
Selection.Sort Key1:=Range("B12"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A12").Select
End Sub

Dave Peterson

Run time error '1004'
 
If you know the password, just have your sort routine unprotect the worksheet,
sort the data and reprotect the sheet.

aeddave wrote:

I assigned a recorded macro to an object. When clicked it sorts range
A12:A2500. It works fine until I turn on sheet protection. The range is not
protected, nor is the object.

I receive the error above with "Sort method of range class failed".
Debugging shows below with "Selection....normal" highlighted.

Any help is appreciated

Sub SortByType()
'
' SortByType Macro
' Macro recorded 1/29/2008 by mcgind1
'

'
Range("A12").Select
Application.Goto Reference:="R12C1:R5000C7"
Selection.Sort Key1:=Range("B12"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A12").Select
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 08:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com