Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
jmp
 
Posts: n/a
Default 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?


--
jmp
------------------------------------------------------------------------
jmp's Profile: http://www.excelforum.com/member.php...o&userid=29038
View this thread: http://www.excelforum.com/showthread...hreadid=487708

  #2   Report Post  
Posted to microsoft.public.excel.misc
Ken Puls
 
Posts: n/a
Default 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" wrote in message
...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clicking Cell Link Changes Cell on Another Sheet nshah Excel Discussion (Misc queries) 1 August 31st 05 01:50 AM
Cell linked to a range of cell values in different sheet szeng Excel Discussion (Misc queries) 1 August 9th 05 02:41 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
The Aarow keys move the entire sheet instead of to the next cell Ric Charts and Charting in Excel 1 April 26th 05 12:33 AM
Automatic cell increment with data from sheet 1 to sheet 2 Big G Excel Worksheet Functions 2 December 20th 04 05:59 PM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"