MAcro works fine on my computer (Excel 2016) but get an error on another computer (Excel 2013) RRS feed

  • Question

  • Hi, I have code that sorts a data list, when I run it on my computer, which runs Excel 2016, it works fine, but when I run it on another computer (which runs Excel 2013) it gives me an error. Any idea on what could change between the two computers?

    I have put the area that gives the error in bold below.

        ActiveWorkbook.Worksheets("TrendData").Sort.SortFields.Add2 Key:=Range( _
            "A1:" & lRow & "1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        With ActiveWorkbook.Worksheets("TrendData").Sort
            .SetRange Range("A1:CM1605")
            .Header = xlGuess
            .MatchCase = False
            .Orientation = xlLeftToRight
            .SortMethod = xlPinYin
        End With

    Friday, February 8, 2019 8:32 PM

All replies

  • Hi icem101590,

    I'm afraid your provided code is not sufficient.
      e.g. a variable "lRow" is not declared in your code. 

    I'd like you to
      (1) provide enough code related to your issue
      (2) share a sample sheet via cloud storage such as OneDrive, Dropbox, etc.
           (Remember to modify your vital/sensitive data before sharing.)


    Ashidacchi --

    Saturday, February 9, 2019 2:33 AM
  • Did you try Add instead of Add2? Maybe Add2 is not available in older versions.

    Saturday, February 9, 2019 8:19 AM
  • Hi,

    I'm afraid if type of a variable "lRow" is Integer or Long, Range("A1:" & lRow & "1") becomes meaningless.
    Anyway, I hope you will share a sample sheet.


    Ashidacchi --

    Saturday, February 9, 2019 8:31 AM