Active Cell in Excel Macros

Closed
bjwaggs - Oct 8, 2010 at 12:39 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Oct 8, 2010 at 10:34 PM
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 June 14, 2009 Status Contributor Last seen August 7, 2021 811
Oct 8, 2010 at 10:34 PM
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
1