+ Reply to Thread
Results 1 to 6 of 6

Amount of number extracted depending on time period

  1. #1
    Registered User
    Join Date
    04-03-2017
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    92

    Post Amount of number extracted depending on time period

    I have two sheets in a workbook, sheet1 and sheet2 (ATTACHED). Sheet 1 contains information regarding where a worker has lived and for how long (from "In" to "Out" in sheet1).
    Sheet 2 contains data regarding the rent for the corresponding apartment. So for "Apartment 1", the worker is supposed to pay for some of January (08-01 2018 - 31-01 2018), for all of February and March,
    and for some of April (01-04 2018 -07-04 2018). For every month is a column called "Rent paid", which should be added to the corresponding month column, in a similar fashion as described above.
    So I basically need a function/code/macro that looks up the apartments for sheet1 in sheet2 and then returns a value in the "Rent" column for the corresponding apartment, with a calculation as described before.
    Ideally, it should distinguish between number of days in a month (31 in Jan, 28 in Feb etc.), but if it is too difficult, assuming 31 days in every month is OK.

    In "Rent" for Apartment1 I manually calculated the desired output (the calculation is in the cell).

    Thank you very much for your help!

    Best regards
    Attached Files Attached Files
    Last edited by Allerdrengen; 02-20-2019 at 11:28 AM.

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Amount of number extracted depending on time period

    Please try at G2

    =SUMPRODUCT(LOOKUP(MONTH(ROW(INDIRECT(E2&":"&F2))),ROW($A$1:$A$12),SUBTOTAL(9,OFFSET(Sheet2!$B$1:$C$1,MATCH(A2,Sheet2!$A$2:$A$8,),ROW($A$1:$A$12)*3-3))/DAY(EOMONTH(DATE(2019,ROW($A$1:$A$12),1),0))))

    8 to 31 Jan should be =31-8+1 =24 days, not 8 days
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-03-2017
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    92

    Re: Amount of number extracted depending on time period

    Thanks for your response! Works like a charm!
    I have one question though, say I have a similar document, but with 3 columns for each month (instead of 2). But still with 1 blank column in between. How do i alter the formula to fit that?

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Amount of number extracted depending on time period

    Not sure, maybe try this, change in red

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-03-2017
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    92

    Re: Amount of number extracted depending on time period

    Thanks for your response, unfortunately that doesn't do the trick.

  6. #6
    Registered User
    Join Date
    04-03-2017
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    92

    Re: Amount of number extracted depending on time period

    Nevermind, it does! Thanks!

+ 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. Deduct amount based on sum of distinct values over a period of time...
    By Mesanic in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-10-2017, 12:11 PM
  2. [SOLVED] Calculate the portion of a planned number during a period, based on another time period
    By BryGuy81 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-19-2017, 01:29 PM
  3. Calculating number of period from total amount allowed
    By jamewoong in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2016, 03:47 PM
  4. Replies: 4
    Last Post: 06-28-2012, 10:33 AM
  5. Replies: 1
    Last Post: 06-28-2012, 10:00 AM
  6. Replies: 1
    Last Post: 01-19-2012, 01:26 AM
  7. Blocking cells depending of the time period
    By Statsman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-10-2008, 02:43 PM

Tags for this Thread

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