Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selecting next cell in column

Status
Not open for further replies.

kragster

Technical User
May 9, 2007
55
DK
Hi,
I am new to VBA, but have programmed a bit before. I am making an application in excell using macros. Is there a simple VBA command to select the next cell in a column?
 




Hi,

Next to WHAT? The ActiveCell? The LAST cell containing a value? Some other cell?

Skip,

[glasses] [red][/red]
[tongue]
 
Oh, sorry. The next cell in the same column, as the current selected cell.
 
Skip is correct in his question and it may sound like splitting hairs but there is a difference to selected cell and active cell!

assuming you mean active cell have a look at the offset method in help

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 




Code:
ActiveCell.Offset(1).Select
But I advise AGAINST using the Select and Activate methods for referencing ranges. It slows the processing down, and in many cases it ASSUMES a starting cell or range at the beginning of a procedure, which is NOT a good practice.

Rather, reference cells and ranges explicitly, using, for instance, the Cells Property...
Code:
For lRow = 2 to ActiveSheet.Range(ActiveSheet.[A2], ActiveSheet.[A2].End(xlDown)) 
  vValue = ActiveSheet.Cells(lRow, 2).value
Next


Skip,

[glasses] [red][/red]
[tongue]
 
ActiveCell.Offset(1).Select

This was exactly what I was looking for. Thanks a bunch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top