+ Reply to Thread
Results 1 to 2 of 2

VBA: move to the next cell down from anywhere in the sheet

  1. #1
    Registered User
    Join Date
    11-23-2005
    Posts
    2

    VBA: move to the next cell down from anywhere in the sheet

    I am deleting rows based on a value in a column (< 16) and if the value is 16 or greater I want to move down to the next row and check that value and so on. i am using a Do Until value = "".

    What is the code for moving down to the next cell below ActiveCell?

  2. #2
    Ken Puls
    Guest

    Re: move to the next cell down from anywhere in the sheet

    Activecell.Offset(1,0).Select

    I would not recommend this though. If you want to delete rows, loop
    backwards through the range (from the bottom up). If you don't, this will
    happen:

    You'll deal with row 15 and delete the row
    Row 16 becomes row 15 and so on (everything shifts up)
    Most users, though, forget this, and go on to the next iteration in the
    loop... which is the current row 16 (previously 17 before it moved up)

    To avoid that issue, try something like this:

    Sub Delete()
    Dim x As Long
    Dim LastRow As Long
    LastRow = Range("A65536").End(xlUp).Row
    For x = LastRow To 1 Step -1
    If range("A" & x).value < 16 then rows(x).entirerow.delete
    Next x
    End Sub


    --
    Ken Puls
    www.officearticles.com

    "jmp" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I am deleting rows based on a value in a column (< 16) and if the value
    > is 16 or greater I want to move down to the next row and check that
    > value and so on. i am using a Do Until value = "".
    >
    > What is the code for moving down to the next cell below ActiveCell?
    >
    >
    > --
    > jmp
    > ------------------------------------------------------------------------
    > jmp's Profile:
    > http://www.excelforum.com/member.php...o&userid=29038
    > View this thread: http://www.excelforum.com/showthread...hreadid=487708
    >




+ 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