Results 1 to 3 of 3

Thread: Step -1 (03)

  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Step -1 (03)

    Is it possible to have code something like this:

    For each oCell in Range("MyRange") Step -1 'Instead of starting at the first cell in the range it starts at the last cell
    Msgbox oCell
    Next oCell

    Thanks,
    John

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Step -1 (03)

    Nope, you'd have to use a normal for-next loop with an index:

    For i=1000 to 1 Step -1
    Cells(i,1).Value=i
    Next
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

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

    Re: Step -1 (03)

    Not with For Each, but like this:
    <code>
    Dim i As Long
    With Range("MyRange")
    For i = .Cells.Count To 1 Step -1
    MsgBox .Cells(i)
    Next i
    End With</code>

Posting Permissions

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