+ Reply to Thread
Results 1 to 5 of 5

Loop through values and sum corresponding values from another sheet

  1. #1
    Registered User
    Join Date
    01-09-2021
    Location
    PA
    MS-Off Ver
    365
    Posts
    2

    Loop through values and sum corresponding values from another sheet

    Hi,

    This is my first time posting here, so my apologies if I make any errors!

    I have a file with two sheets- Sheet1 of different people's start and end years and Sheet2 of years' corresponding incomes. I would like to loop through each person's start and end year and sum the corresponding years' incomes from Sheet2 into the Sheet1 column Summed Income.
    For example, for person 1, whose Start is 2009 and End is 2011, I want Summed Income to take on the sum of the incomes from Sheet2 for 2009, 2010, and 2011, i.e. 930.

    I'm not sure if this can be done with just a formula or if it requires VBA, so I'm asking here, but apologies if this is the wrong spot for my question. I've attached a sample file.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,767

    Re: Loop through values and sum corresponding values from another sheet

    Hi & welcome to the board.
    How about, in E2 copied down
    =SUMIFS(Sheet2!B:B,Sheet2!A:A,">="&B2,Sheet2!A:A,"<="&C2)

  3. #3
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Loop through values and sum corresponding values from another sheet

    Try this VBA code, although this could also be done via formulas. It also computes the elapsed years.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-09-2021
    Location
    PA
    MS-Off Ver
    365
    Posts
    2

    Re: Loop through values and sum corresponding values from another sheet

    Thank you both!!

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,767

    Re: Loop through values and sum corresponding values from another sheet

    You're welcome & thanks for the feedback.

+ 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. Loop through the list and record values in another sheet
    By maorlov in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-27-2019, 10:04 AM
  2. [SOLVED] Loop through shapes in each sheet and count the values along with sheet name
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2016, 12:09 PM
  3. Replies: 4
    Last Post: 10-05-2012, 02:58 PM
  4. loop through values in listbox and search for them in excel sheet
    By longhorn23 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-29-2010, 08:32 PM
  5. Loop through cells compare values add and move to another sheet
    By begilhang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2010, 04:07 AM
  6. Insert values from one sheet to another with a Loop
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-11-2008, 09:17 AM

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