Navigating
Typo, sorry. Missed a currentColumn in there, but you
probably caught that.
-----Original Message-----
The crntRow and crntCol are just a reference to whatever
the cell was when you set them (crntRow =
ActiveCell.Row). If you do something like Cells(crntRow
+ 1, crntCol).Activate, it will activate the next cell
in
that row. It will not change the reference cell,
however. If you want to change the reference cell, so
that moving one more row down would still involve a
crntRow + 1, you have to update the reference cell to be
equal to the currently selected cell. Here is an
example.
currentRow = ActiveCell.Row
currentColumn = ActiveCell.Column
Cells(currentRow + 1).Activate
Cells(currentRow + 2).Activate
The above is the same as doing this:
currentRow = ActiveCell.Row
currentColumn = ActiveCell.Column
Cells(currentRow + 1).Activate
' set the new reference cell
currentRow = ActiveCell.Row
currentColumn = ActiveCell.Column
Cells(currentRow + 1, currentColumn).Activate
Don't think of currentRow and currentColumn as the
parameters for the cell that is active. Think of them
as
the parameters for the cell that WAS active when you
defined them.
-----Original Message-----
Hi Ryan
Your assumption is correct; I am working in VBA.
Let's say crntRow = 10 and crntCol = H
Therefore Cells(crntRow + 1, crntCol).Activate is H11
Now if I want to move to H12, is that
Cells(crntRow + 1, crntCol).Activate or is it
Cells(crntRow + 2, crntCol).Activate?
And also, is there a shortcut way of moving to the end
of
a row or column?
One last thing is that I saw the following constants in
a
piece of code but don't know if they apply or how to
use
them, xlDown, xlUp, xlToLeft, xlToRight, xlRight, xlLeft
Thanks for your help!
Hafeez Esmail
-----Original Message-----
I assume you are working in VBA.
currentRow = ActiveCell.Row
currentColumn = ActiveCell.Column
Next Row:
Cells(currentRow + 1, currentColumn).Activate
Next Column:
Cells(currentRow, currentColumn + 1).Activate
Previous Row:
Cells(currentRow - 1, currentColumn).Activate
Previous Column:
Cells(currentRow, currentColumn - 1).Activate
Does this help?
Ryan
-----Original Message-----
I've looked all over for this info but can't find it.
If my active cell is H396, how would I do the
following?
Move one cell to the left/right/up/down?
Move to the bottom of this column?
Move to the end of this row?
Thanks
Hafeez Esmail
.
.
.
.
|