>>I'm still trying to get a grip on your technique. Suppose you captured a cell reference as in
>>
>>cell1 = .activecell
>>
>>then moved the cursor somewhere else and
>>
>>cell2 = .activecell
>>
>>Cell1 and cell2 now define the boundries of a range. How would you specify the sum of that range?
>>
>>* move again and . . .
>>.selection.value = '=sum(' + cell1 ':' cell2 + ')'
>>
>
>1. To insert a formula, you don't use .Value, but .FormulaR1C1. (Try saving a macro, and look at the results.)
>2. This formula expects a text, not a range object.
>
>For example, if I save a macro and create a sum for the 3 cells above, I get:
>
>
>ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)"
>
>
>Considering that the number of rows might vary, I might change this to:
>
>
>loSheet.Cells(lnRow, xlCol_F).FormulaR1C1 = "=SUM(R[-" + transform(lnNumRows);
> + "]C:R[-1]C)"
>
>
>Where:
>
loSheet is an object reference to an Excel sheet
>xlCol_F is defined as: #DEFINE xlCol_F 6
>lnNumRows contains the number of rows I need to add. In practice, I usually use some other expression in this case.
>
>HTH,
>
>Hilmar.
Hilmar -
Thanks, that gets me there.