Detecting Active Cell

M

Mike Hogan

Is there a worksheet function, or some other method, that will return
a reference to the active cell? By active cell, I mean the last cell
pointed to and clicked on. Thanks for any help.

Mike
 
S

sjoo.kwak

Get.Cell() macro function is returning various information of a cell.

GET.CELL(type_num, reference)
Returns information about the formatting, location, or contents of a
cell.
Use GET.CELL in a macro whose behavior is determined by the status of a
particular cell.

Type_num : a number that specifies what type of cell information you
want(1~66)
Reference : a cell or a range of cells from which you want information

Type_num : 1 -> Absolute type address of Cell
Type_num : 2 -> row of Cell
Type_num : 3 -> Column of Cell
Type_num : 4 -> Value of Cell
Type_num : 6 -> Formula of Cell
....
....

But you can use this function not in worksheet formula but at vba
module or the naming dialogbox.

for the more information, Please googling GET.CELL

Best regards,
 
H

Harlan Grove

Mike Hogan wrote...
Is there a worksheet function, or some other method, that will return
a reference to the active cell? By active cell, I mean the last cell
pointed to and clicked on. Thanks for any help.

The closest formula approach would be =CELL("Address"), but it won't
automatically recalc just by changing the active cell or current
selection. If you need to track the active cell automatically, you need
to use either a worksheet level SelectionChange event handler or a
workbook level SheetSelectionChange event handler. Event handlers are
special VBA macros that run when particular events occur.

Put the following code into the active worksheet's code (right click on
the worksheet's tab and select View Code to launch the VB Editor, and
paste the following into it)

'-- begin copy --
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox Prompt:=Target.Address(0, 0), Title:="Active Cell"
End Sub
'-- end copy --

Switch back to Excel and select different cells in that worksheet.
 

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