+ Reply to Thread
Results 1 to 7 of 7

#value error from edate function inside an if statment to get one of two numbers

  1. #1
    Registered User
    Join Date
    02-13-2021
    Location
    ottawa
    MS-Off Ver
    2017
    Posts
    10

    #value error from edate function inside an if statment to get one of two numbers

    A.png


    The error is with using the EDATE function.


    The goal is to get the correct total loss of income of a given month.

    From the attached excel document...

    Given a set of two numbers under columns titled "base rent" and "new rent", check to see if the month of the current date "TODAY()" IS >= a given date.

    We do this to subtract the cost of all cells that contain the word "vacant" to adjust the expected income for a month.


    • Attached is an excel document with the problem areas marked in red.
    • Conditional formating was used to highlight cells that contain the word "vacant" black.

    Below is the formula I'm trying to use to solve this problem.

    Please Login or Register  to view this content.
    Given the formula above, I'm understanding it as:
    1. Get the sum of everything in a column
    2. if a cell contains the word vacant then
    3. if the current integer obtained from the (month) function that gets a date from a cell from B2:b13 with the date forward by 3 months due to EDATE(B2:b13,3) function, if the integer is greater then or equal to the value of the cell E19 (1, in this case) then subtract the value in the "new Rent" Column
    4. Else subtract from the rent from the base rent column.


    The correct expected total loss should be -3000$.
    Attached Files Attached Files
    Last edited by skite0; 03-25-2021 at 05:33 PM. Reason: spelling errors

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: #value error from edate function inside an if statment to get one of two numbers

    Hi,
    Try this maybe:
    =SUM(IF(ISNUMBER(SEARCH("vacant",E2:E11)),((MONTH($C$2:$C$11)>=E18)*(-1*D2:D11)+(MONTH($C$2:$C$11)<=E18)*(-1*A2:A11))))

  3. #3
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: #value error from edate function inside an if statment to get one of two numbers

    I even think this part is redundant:
    =SUM(IF(ISNUMBER(SEARCH("vacant",E2:E11),(MONTH($C$2:$C$11)>=E18)*(-1*D2:D11)+(MONTH($C$2:$C$11)<=E18)*(-1*A2:A11))))
    Last edited by Limor_OP; 03-26-2021 at 05:09 AM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: #value error from edate function inside an if statment to get one of two numbers

    Try

    =SUMPRODUCT(((E2:E11="Vacant")*((MONTH(C2:C11)>=E18)*-(D2:D11))+(MONTH(C2:C11)<=E18)*-(A2:A11)))

    based on post #3 formula

  5. #5
    Registered User
    Join Date
    02-13-2021
    Location
    ottawa
    MS-Off Ver
    2017
    Posts
    10

    Re: #value error from edate function inside an if statment to get one of two numbers

    Quote Originally Posted by JohnTopley View Post
    Try

    =SUMPRODUCT(((E2:E11="Vacant")*((MONTH(C2:C11)>=E18)*-(D2:D11))+(MONTH(C2:C11)<=E18)*-(A2:A11)))

    based on post #3 formula

    Quote Originally Posted by belinda200 View Post
    Hi,
    Try this maybe:
    =SUM(IF(ISNUMBER(SEARCH("vacant",E2:E11)),((MONTH($C$2:$C$11)>=E18)*(-1*D2:D11)+(MONTH($C$2:$C$11)<=E18)*(-1*A2:A11))))
    I would like to thank both of you for giving me the basis to improve what I had. While your solutions did work, I forgot to mention that the year should also be taken into account.

    With this in mind I've refactored the formula to this:


    Please Login or Register  to view this content.
    I'm going to test it a bit more but I'll let you know if it works

  6. #6
    Registered User
    Join Date
    02-13-2021
    Location
    ottawa
    MS-Off Ver
    2017
    Posts
    10

    Re: #value error from edate function inside an if statment to get one of two numbers

    Thanks you two, I finally got it to work :D

    I ended up going with
    Please Login or Register  to view this content.
    Into:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: #value error from edate function inside an if statment to get one of two numbers

    Very nice skite0 , good work : )

+ 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. 'While' function inside of error handler giving an error/failing
    By dnwadams in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2015, 12:18 AM
  2. IF statement not working with text function and edate function.
    By joshnathan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-04-2013, 10:26 AM
  3. edate error
    By elde in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-10-2007, 11:06 AM
  4. Edate function Name error
    By SharonP. in forum Excel General
    Replies: 1
    Last Post: 05-02-2006, 02:25 PM
  5. [SOLVED] edate function
    By Candace in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-02-2005, 06:17 PM
  6. [SOLVED] #NAME? error using EDATE
    By Zimbob79 in forum Excel General
    Replies: 2
    Last Post: 03-25-2005, 11:06 PM
  7. The Help on the Excel Edate worksheet function contains an error:.
    By Guido in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-20-2005, 10:06 AM

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