var1 = worksheets (1).name ' First
w = worksheets.count
var2 = worksheets(w).name ' Last
ActiveCell.FormulaR1C1 = "=SUM(" & var1 & ":" & var2 & "!RC)"
--
Regards,
Tom Ogilvy
"JT" wrote:
> I would like to insert the following formula on the first sheet in the my
> workbook to add up the same cell on each sheet in the workbook.
>
> var1 = worksheets (1).name ' First
> w = worksheets.count
> var2 = worksheets(w).name ' Last
>
> ActiveCell.FormulaR1C1 = "=SUM(First:Last!RC)"
>
> I got this formula by recording a macro in Excel to get started. "First"
> and "Last" are the sheet names for this workbook.
>
> I would like to use 2 variables for the first and last worksheets (instead
> of hard coding the sheet names since the names will be different depending on
> the user.
>
> I tried to put the above formula in a macro (with variables for the sheet
> name) but when I look at the activecell, the formula is displayed instead of
> the result.
>
> Any help would be greatly appreciated. Thanks for your help..........
> --
> JT
Bookmarks