Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sort method of range class failed

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I am getting the error "sort method of range class failed" on the following code:

After a button is clicked on a userform its sorting a sheet on a particular row.

It used to work but now its not.

Any ideas how I correct this:

Code:
If Not Intersect(Target, Range("F:F")) Is Nothing Then
        Range("F1").Sort Key1:=Range("F2"), _
          Order1:=xlAscending, Header:=xlYes, _
          OrderCustom:=1, MatchCase:=False, _
          Orientation:=xlTopToBottom
    End If
 
Sorry this is my entire code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    With Target
        If .Count > 1 Then Exit Sub
        
        If .Value = "Approved for archive" Then
            .EntireRow.Copy
            
            Sheets("Archived").Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial _
            Paste:=xlPasteValues
            Application.CutCopyMode = False

        End If
    End With
    
   
    If Not Intersect(Target, Range("F:F")) Is Nothing Then
        Range("F1").Sort Key1:=Range("F2"), _
          Order1:=xlAscending, Header:=xlYes, _
          OrderCustom:=1, MatchCase:=False, _
          Orientation:=xlTopToBottom
    End If
    
    
    End Sub
 
Hi,

Code:
With target
    If Not Intersect(.cells, .parent.Range("F:F")) Is Nothing Then
        .Parent.Range("F1").Sort Key1:=.parent.Range("F2"), _
          Order1:=xlAscending, Header:=xlYes, _
          OrderCustom:=1, MatchCase:=False, _
          Orientation:=xlTopToBottom
    End If
End with


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top