+ Reply to Thread
Results 1 to 6 of 6

VBA Sum Same Cell Across Multiple dynamic Worksheets (in name and number)

  1. #1
    Registered User
    Join Date
    09-08-2016
    Location
    Boston
    MS-Off Ver
    Office 365
    Posts
    4

    VBA Sum Same Cell Across Multiple dynamic Worksheets (in name and number)

    Hi,

    I'm trying to use this code to sum the same cell across multiple worksheets in different ranges: ActiveCell.FormulaR1C1 = "=SUM('*'!D19)"
    I have the following issue:
    1) When I input the formula manually it works perfect but when I use VBA the cells throws the following error: #NAME?

    I need to use the code above because the worksheets varies in number and names every time I run a different macro.
    What am I missing?
    Thanks,
    WALDIR

    This is the full macro:
    [Code]
    Sub SumSameCellAcrossMultipleSheets()
    Dim r1 As Range
    Dim r2 As Range
    Dim r3 As Range
    Set r1 = Range("D19:BK29")
    Set r2 = Range("D35:BK46")
    Set r3 = Range("D52:BK61")

    Sheets("Template").Select
    Range("D19").Select
    ActiveCell.FormulaR1C1 = "=SUM('*'!D19)"
    Range("D19").Select
    Selection.Copy

    r1.Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    r2.Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    r3.Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    End Sub
    [Code//]

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: VBA Sum Same Cell Across Multiple dynamic Worksheets (in name and number)

    Try Formula instead of FormulaR1C1
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-08-2016
    Location
    Boston
    MS-Off Ver
    Office 365
    Posts
    4

    Re: VBA Sum Same Cell Across Multiple dynamic Worksheets (in name and number)

    That made the whole trick!

    Thank you so much!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: VBA Sum Same Cell Across Multiple dynamic Worksheets (in name and number)

    You're welcome. Thanks for the rep.


    I learned something new too ... I've never seen that syntax before. Thanks.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  5. #5
    Registered User
    Join Date
    09-08-2016
    Location
    Boston
    MS-Off Ver
    Office 365
    Posts
    4

    Re: VBA Sum Same Cell Across Multiple dynamic Worksheets (in name and number)

    Definitely TMS,

    I'll mark the thread as solved.
    In regards of the little start at the bottom, I clicked on it on your behalf yesterday.

    Thank you!

  6. #6
    Registered User
    Join Date
    09-08-2016
    Location
    Boston
    MS-Off Ver
    Office 365
    Posts
    4

    Re: VBA Sum Same Cell Across Multiple dynamic Worksheets (in name and number)

    Definitely TMS,

    I'll mark the thread as solved.
    In regards of the little start at the bottom, I clicked on it on your behalf yesterday.

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy rows from multiple worksheets with multiple criteria - greater than dynamic values
    By stackout in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2015, 04:36 PM
  2. [SOLVED] Sum across multiple worksheets with dynamic cell addresses
    By tatiana_ in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-14-2015, 07:25 AM
  3. sum offset same dynamic range across multiple worksheets
    By warabella in forum Excel General
    Replies: 1
    Last Post: 07-22-2013, 11:52 PM
  4. Insert a number of rows based on a cell value and copy formulas on multiple worksheets
    By Charleneq40 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2012, 12:45 PM
  5. Replies: 1
    Last Post: 03-08-2012, 09:42 AM
  6. Dynamic values in multiple worksheets
    By ninosportif in forum Excel General
    Replies: 0
    Last Post: 04-13-2009, 01:17 AM
  7. Looping through dynamic ranges from multiple worksheets
    By TechWrangler in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2006, 03:20 PM

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