I'm trying to write some code that will select the top of a contiguous range relative to the actively selected cell, and use that in a formula. So far I have the following:
In this example, I would like to replace the R[-4] component with a construct that will relatively select the top of the contiguous range above the active cell. For example, if there are 15 contiguous cells cells in the column above, the code would plug the top cell automatically instead of just going up 4 rows each time.
To be clear, I am purposefully using the OFFSET convention in the SUM formula. I would like to be able to automate the SUM shortcut of "Alt =" but instead of having a SUM Range, I would like to have a range that sums even if I add rows between the stack of data above the total
Not partial to R1C1 either...would prefer not to use it if possible.
Thank you for any help!
Code:
ActiveCell.FormulaR1C1 = "=SUM(R[-4]C:OFFSET(RC,-1,0))"
In this example, I would like to replace the R[-4] component with a construct that will relatively select the top of the contiguous range above the active cell. For example, if there are 15 contiguous cells cells in the column above, the code would plug the top cell automatically instead of just going up 4 rows each time.
To be clear, I am purposefully using the OFFSET convention in the SUM formula. I would like to be able to automate the SUM shortcut of "Alt =" but instead of having a SUM Range, I would like to have a range that sums even if I add rows between the stack of data above the total
Not partial to R1C1 either...would prefer not to use it if possible.
Thank you for any help!