jwise
01-15-2008, 06:46 PM
The size of my data (the number of columns) is variable. How would I put a formula in an additional column that added together all the previous columns?
For example, suppose my spreadsheet is 3x3 data values. I want a macro to insert "=AVG(A1:C1) " into cell D1. I can already do this if the exact range is known beforehand, but my macro is of limited use since it is tied to the exact number of columns. I want this macro to work for a variable number of columns.
I used the construct:
Range(Cells(1, 1), Cells(3, 1))
to copy the formula down the rows, but I don't think this will work in a formula. TIA
For example, suppose my spreadsheet is 3x3 data values. I want a macro to insert "=AVG(A1:C1) " into cell D1. I can already do this if the exact range is known beforehand, but my macro is of limited use since it is tied to the exact number of columns. I want this macro to work for a variable number of columns.
I used the construct:
Range(Cells(1, 1), Cells(3, 1))
to copy the formula down the rows, but I don't think this will work in a formula. TIA