Active Cell in Excel Macros

Closed
bjwaggs - 8 Oct 2010 à 12:39
venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 - 8 Oct 2010 à 22:34
Hey, I'm pretty new to using Excel macros. I'm writing a macro that will be activated from many different cells. It needs to reference some static cell locations regardless of where it is activated and some cell locations relative to where it is activated. To do this I need to "get back to my starting point" but I can't figure out how to determine (and store) the location of the active cell when the macro is first activated.

It seems like determining your current location should be quite simple but I'm stumped.

Thanks.
Related:

1 response

venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 811
8 Oct 2010 à 22:34
give the starting cell a variable name

eg.
dim r as range
setr=range("A1")

if A1 is the starting cell

subsequently you use r instead of A1