+ Reply to Thread
Results 1 to 2 of 2

syntax issue

  1. #1
    JT
    Guest

    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. #2
    Tom Ogilvy
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1