+ Reply to Thread
Results 1 to 3 of 3

Macro giving runtime error on one PC and not another

  1. #1
    Ingrid
    Guest

    Macro giving runtime error on one PC and not another

    In the following code, the macro gives a runtime error 1004: application or
    object defined error at the Selection.Sort command.

    Sheets("Data").Select
    Cells.Select
    Selection.Font.Bold = False
    Selection.Sort Key1:=Range("A2"), Order1:=xlDescending,
    Key2:=Range("B2") _
    , Order2:=xlDescending, Header:=xlYes, OrderCustom:=1,
    MatchCase:=False _
    , Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
    DataOption2:= _
    xlSortNormal


    The macro works fine for me with Excel 2003, but not for my friend who has
    Excel 2000. Is there something in the code that could be removed and still
    let the macro function on his pc?

    Or is there a setting in his Excel that needs to be changed to allow this to
    work?

    Thanks!


  2. #2
    Ingrid
    Guest

    RE: Macro giving runtime error on one PC and not another

    Thanks so much - very helpful!

    "Jim Thomlinson" wrote:

    > Remove the DataOption2:= xlSortNormal. It is a new feature in 2003 that did
    > not exist in 2000. xlSortNormal is the default so it does not make a
    > difference anyway...
    >
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "Ingrid" wrote:
    >
    > > In the following code, the macro gives a runtime error 1004: application or
    > > object defined error at the Selection.Sort command.
    > >
    > > Sheets("Data").Select
    > > Cells.Select
    > > Selection.Font.Bold = False
    > > Selection.Sort Key1:=Range("A2"), Order1:=xlDescending,
    > > Key2:=Range("B2") _
    > > , Order2:=xlDescending, Header:=xlYes, OrderCustom:=1,
    > > MatchCase:=False _
    > > , Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
    > > DataOption2:= _
    > > xlSortNormal
    > >
    > >
    > > The macro works fine for me with Excel 2003, but not for my friend who has
    > > Excel 2000. Is there something in the code that could be removed and still
    > > let the macro function on his pc?
    > >
    > > Or is there a setting in his Excel that needs to be changed to allow this to
    > > work?
    > >
    > > Thanks!
    > >


  3. #3
    Dave Peterson
    Guest

    Re: Macro giving runtime error on one PC and not another

    FYI only. It's in xl2002, too <bg>.

    Jim Thomlinson wrote:
    >
    > Remove the DataOption2:= xlSortNormal. It is a new feature in 2003 that did
    > not exist in 2000. xlSortNormal is the default so it does not make a
    > difference anyway...
    >
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    > "Ingrid" wrote:
    >
    > > In the following code, the macro gives a runtime error 1004: application or
    > > object defined error at the Selection.Sort command.
    > >
    > > Sheets("Data").Select
    > > Cells.Select
    > > Selection.Font.Bold = False
    > > Selection.Sort Key1:=Range("A2"), Order1:=xlDescending,
    > > Key2:=Range("B2") _
    > > , Order2:=xlDescending, Header:=xlYes, OrderCustom:=1,
    > > MatchCase:=False _
    > > , Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
    > > DataOption2:= _
    > > xlSortNormal
    > >
    > >
    > > The macro works fine for me with Excel 2003, but not for my friend who has
    > > Excel 2000. Is there something in the code that could be removed and still
    > > let the macro function on his pc?
    > >
    > > Or is there a setting in his Excel that needs to be changed to allow this to
    > > work?
    > >
    > > Thanks!
    > >


    --

    Dave Peterson

+ 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