View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default 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