Macros in Excel (Arguments)
I am writing a macro which works on a template in excel. The template has a matrix which can vary in size. The objective is to calculate basic time from observed times. There are x amount of actions for which times are observed and y number of observations. The actions occur in cycles and therefore the observed times move down a column and back up to the next column. In other words The basic time for the first action in column E would have the formula:
(Last observed time in coloumn D -first observed time in column E).
My Question is: How do I insert a formula into say cell E2 if the macro must determine the last observed time?
An example of code for an ordinary formula is as follows:
ActiveCell.FormulaR1C1 = "=R[-1]C-R[20]C[-1]"
This is however for a fixed amount of actions.
Is there some method by which I can pass an integer variable? For example:
i = { the index of the last cell containing last observed time value)
ActiveCell.FormulaR1C1 = "=R[-1]C-R[i]C[-1]"
Can anyone help or suggest an alternative. It would be appreciated.