View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Claudia d'Amato Claudia d'Amato is offline
external usenet poster
 
Posts: 26
Default How to get from inside a VB macro the currently marked cell?

Both suggested commands do NOT work.
If I use them e.g. in a command like:

Set baseCell = ActiveSheet.Range(Activecell)

or

Set baseCell = ActiveSheet.Range(Selection.cells(1))

then Excel crashes with the following popup:

"Run-time error '1004':
Application defined of object-defined error"

What's wrong?

Other possibilities of getting the currently marked cell?

Claudia

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