Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default syntax issue

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default syntax issue

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
right syntax pls123 Excel Worksheet Functions 8 May 6th 10 05:18 AM
SQL syntax Jeffiec Excel Programming 1 June 14th 05 05:47 PM
Names.Add - Range Syntax Issue Arturo Excel Programming 4 April 22nd 05 04:04 PM
Need help with Syntax Marty Excel Programming 6 June 22nd 04 02:38 AM
Syntax Michael[_23_] Excel Programming 1 December 30th 03 10:08 PM


All times are GMT +1. The time now is 12:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"