+ Reply to Thread
Results 1 to 2 of 2

Type mismatch error

Hybrid View

kishoremcp Type mismatch error 01-31-2013, 03:13 PM
OllieB Re: Type mismatch error 01-31-2013, 03:29 PM
  1. #1
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Post Type mismatch error

    Hi,
    I have the following macro with me which is giving me an error message type mismatch with run time error 13 when i run it. Pleaes help me in fixing it..
    Sub sort()
        Dim lngLastRow As Long
        Dim rngAddress
        lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    rngAddress = Range("A1:AZ1").Find("Document Date").Address
      rngAddress = Mid(rngAddress, 2, 1)
      
    'Sorting based on document date
        ActiveWorkbook.Worksheets("HC6B").sort.SortFields.Clear
        ActiveWorkbook.Worksheets("HC6B").sort.SortFields.Add Key:=(rngAddress & "2:" & rngAddress & lngLastRow), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("HC6B").sort
            .SetRange Range("A1:AC12")
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
          
    End Sub

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Type mismatch error

    Type mismatch can occur when the value provided to the Key:=(...) does not equate to a proper range value. Try debugging the value calculated
    Last edited by OllieB; 01-31-2013 at 03:36 PM.
    If you like my contribution click the star icon!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1