+ Reply to Thread
Results 1 to 5 of 5

Using VBA to sum cells in different worksheets based on a loop

  1. #1
    Registered User
    Join Date
    09-28-2020
    Location
    UK
    MS-Off Ver
    2013
    Posts
    21

    Using VBA to sum cells in different worksheets based on a loop

    Hi, I have a simple attachment below with 6 sheets. Four of them are just duplicates with 1 to 10 written out in cells a1-j1. The 'list' sheet has the names of some of these duplicate sheets, and the 'total' sheet is where I want my macro to be and work. I have already put a macro together as such:

    Please Login or Register  to view this content.
    What this is trying to do is go to the 'list' sheet, and if the 'list' sheet has the names of certain other sheets in column A, it should add the relevant cell of those particular sheets. For example, the list sheet has test 20, 25 and 26 in column A. Therefore, a1 of my 'total' sheet should be ='test 20'!a1+'test 25'!a1+'test 26'!a1. A2 would be ='test 20'!a2+'test 25'!a2+'test 26'!a2. If I deleted test 26 from list, it would just be ='test 20'!a1+'test 25'!a1 in a1.

    Could someone help with this please?
    Attached Files Attached Files
    Last edited by ExcelDropper; 03-18-2022 at 05:43 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,734

    Re: Using VBA to come cells in different worksheets based on a loop

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-28-2020
    Location
    UK
    MS-Off Ver
    2013
    Posts
    21

    Re: Using VBA to come cells in different worksheets based on a loop

    sorry, updated

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,575

    Re: Using VBA to sum cells in different worksheets based on a loop

    Chage 5 to suite
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-28-2020
    Location
    UK
    MS-Off Ver
    2013
    Posts
    21

    Re: Using VBA to sum cells in different worksheets based on a loop

    tyvm! worked perfectly

+ 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] Loop through Worksheets and format data as Table based on keyword
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-26-2020, 12:14 AM
  2. Vba code to loop thru worksheets based on criteria
    By Godlovesmeplenty in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-09-2015, 12:26 PM
  3. [SOLVED] Open & loop through worksheets based on filename cell value
    By ryanpetersen in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-05-2014, 03:16 PM
  4. [SOLVED] loop through column, create worksheets based on data within
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-11-2012, 12:50 AM
  5. Loop through worksheets which are defined in a range of cells
    By OilMan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-23-2010, 02:37 AM
  6. Loop through cells and then through all worksheets
    By jeffreybrown in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2010, 04:21 PM
  7. Replies: 3
    Last Post: 04-28-2007, 01:46 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