How do I get the coordinates of the active cell in Excel?

G

Guest

I want to find the row and column numbers of the active cell so that I can
use them as variables in an Excel worksheet.
 
R

Rick Rothstein \(MVP - VB\)

I want to find the row and column numbers of the active cell
so that I can use them as variables in an Excel worksheet.

I presume you mean in a macro...

TheActiveRow = ActiveCell.Row

TheActiveColumn = ActiveCell.Column

Rick
 
S

Stan Brown

Sun, 17 Jun 2007 11:30:00 -0700 from <=?Utf-8?B?SmltIFN0dWFydA==?=
I want to find the row and column numbers of the active cell so that I can
use them as variables in an Excel worksheet.

Do you want these in a VBA macro or in a worksheet? In a worksheet,
=ROW() is the current row number and =COLUMN() is the current column
number.
 
E

Earl Kiosterud

Jim,

Since you said active cell, I presume you mean in VBA:

ActiveCell.Row or ActiveCell.Column

If you mean in a worksheet:

=ROW() OR COLUMN().

The above yields the row or column that the formula lives in.
--
Earl Kiosterud
www.smokeylake.com

Note: Top-posting has been the norm here.
Some folks prefer bottom-posting.
But if you bottom-post to a reply that's
already top-posted, the thread gets messy.
When in Rome...
 
G

Guest

Earl, Stan,
I am working in Excel and don't know much about Visual Basic or Macros.
Rick has given me a response which would probably help me if I did, but the
fact is I can't make it work.

ROW() or COLUMN() just give the coordinates of the cell that the formula is
written in.
I want to know the current coordinates of the cell that the "cursor" is in.
The values should change as I use the arrows to move around the worksheet.
Thanks,
Jim
 
R

Rick Rothstein \(MVP - VB\)

I am working in Excel and don't know much about Visual Basic or Macros.
Rick has given me a response which would probably help me if I did, but
the
fact is I can't make it work.

ROW() or COLUMN() just give the coordinates of the cell that the formula
is
written in.
I want to know the current coordinates of the cell that the "cursor" is
in.
The values should change as I use the arrows to move around the worksheet.

I think you will need to tell us more than you have about how you plan to
use this information. The reason your question, as stated so far, is
confusing is that you seem to want to "see" the active cell's row and column
while in the worksheet... but "active cell" is always being displayed in the
field located next to the formula bar, so you have to have something
"deeper" in mind with your question.... I think we are just having trouble
seeing what it is.

Rick
 
G

Guest

Rick,
That's the frustrating part. I can see the information I want in the upper
left corner of the worksheet, but I can't use it in calculations.
I plan to display list of items on a workwheet where the user can scroll
through them using the cursor or arrows.
For each item there is an associated description that I want to display in a
separate part of the worksheet. If I could get the row and column of the
cell that the user is looking at at the moment, I could use that information
to look up the description.
I'm surprised that there isn't an Excel function that does this.
Thanks again,
Jim
 
G

Guest

Rick, Earl, Stan,
I found my answer on another help topic as follows.

Copy this event in the sheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A1").Value = Cells(Target.Row, Target.Column).Address(False, False)
End Sub

Works like a slingshot.

Thank you all for your help.
Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top