Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    168
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Runtime error (office 2000)

    Good Evening,
    I am constantly running into a

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Runtime error (office 2000)

    You select a range of cells in columns A and B, then try to sort it on column I. That is not valid. Depending on what you want, you should either expand the range, or sort on either column A or column B.

    By the way, it is not necessary to select a range to sort it in code:

    Range("A20:I580").Sort Key1:=Range("I8"), Order1:=xlDescending, Header:=xlGuess _
    , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal

    is more efficient.

  3. #3
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Runtime error (office 2000)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> cvbs

    Whe you say: Selection.Sort Key1:=Range("I8"), is that I-8, or 18? There is no range named 18, and -8 is outside the range you are sorting?

    And just so I understand what you are trying to do, what is above your sort range, 18 = 1-17, or I-8 = I-1:I-7?

    Usually the sort is done by a column header which usually is the first row. Excel can recognize it if it has a different font color, or is alphabetic while the data is numeric.

    So something like I1 or A1, will make more sense.

    Maybe you need to rething your worksheet design.

    HTH

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

Posting Permissions

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