ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to get from inside a VB macro the currently marked cell? (https://www.excelbanter.com/excel-discussion-misc-queries/243372-how-get-inside-vbulletin-macro-currently-marked-cell.html)

Claudia d'Amato

How to get from inside a VB macro the currently marked cell?
 
Assume I have opened a worksheet and marked exactly one cell (e.g. D47).

Now I want to run a VB macro. How can I find out from inside this macro
which cell is currently marked in the current worksheet?

This should look similar to:

Set baseCell = ActiveSheet.Range(getcurrentlymarkedcell())

Obviously "getcurrentlymarkedcell()" does not exists. Which function can I use instead?

If the user accidentially marked a range of cells instead of a single cell then only the
first/upper+leftmost cell should be returned.

Claudia


Dave Peterson

How to get from inside a VB macro the currently marked cell?
 
Maybe

Activecell
or
Selection.cells(1)





Claudia d'Amato wrote:

Assume I have opened a worksheet and marked exactly one cell (e.g. D47).

Now I want to run a VB macro. How can I find out from inside this macro
which cell is currently marked in the current worksheet?

This should look similar to:

Set baseCell = ActiveSheet.Range(getcurrentlymarkedcell())

Obviously "getcurrentlymarkedcell()" does not exists. Which function can I use instead?

If the user accidentially marked a range of cells instead of a single cell then only the
first/upper+leftmost cell should be returned.

Claudia


--

Dave Peterson

Dave Peterson

How to get from inside a VB macro the currently marked cell?
 
And if your macro is a user defined function and you're trying to find the cell
that holds the formula:

application.caller



Dave Peterson wrote:

Maybe

Activecell
or
Selection.cells(1)

Claudia d'Amato wrote:

Assume I have opened a worksheet and marked exactly one cell (e.g. D47).

Now I want to run a VB macro. How can I find out from inside this macro
which cell is currently marked in the current worksheet?

This should look similar to:

Set baseCell = ActiveSheet.Range(getcurrentlymarkedcell())

Obviously "getcurrentlymarkedcell()" does not exists. Which function can I use instead?

If the user accidentially marked a range of cells instead of a single cell then only the
first/upper+leftmost cell should be returned.

Claudia


--

Dave Peterson


--

Dave Peterson


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com