+ Reply to Thread
Results 1 to 11 of 11

IF, AND, DATE Syntax issue

Hybrid View

Matthew55 IF, AND, DATE Syntax issue 11-14-2017, 12:37 PM
63falcondude Re: IF, AND, DATE Syntax issue 11-14-2017, 12:43 PM
Jonmo1 Re: IF, AND, DATE Syntax issue 11-14-2017, 12:57 PM
Jonmo1 Re: IF, AND, DATE Syntax issue 11-14-2017, 12:49 PM
Jonmo1 Re: IF, AND, DATE Syntax issue 11-14-2017, 01:21 PM
Matthew55 Re: IF, AND, DATE Syntax issue 11-14-2017, 01:40 PM
JohnTopley Re: IF, AND, DATE Syntax issue 11-14-2017, 01:41 PM
Matthew55 Re: IF, AND, DATE Syntax issue 11-14-2017, 01:53 PM
Jonmo1 Re: IF, AND, DATE Syntax issue 11-14-2017, 02:05 PM
Matthew55 Re: IF, AND, DATE Syntax issue 11-14-2017, 02:17 PM
Jonmo1 Re: IF, AND, DATE Syntax issue 11-14-2017, 02:22 PM
  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2016
    Posts
    52

    IF, AND, DATE Syntax issue

    Hello,

    I started with a formula formula which looks only at a static date field $D$5; however the need has arisen such that a different date $AG49 should be used if it is greater than (>) $D$5. I added the syntax "IF($AG49>$D$5,$AG49,$D$5)" to the formula and receive the "Not trying to type a formula?" error. I'm not certain where the error lies - do I not have the appropriate number of parentheses, are they in the wrong place or are my arguments in an unacceptable order.

    Help please...

    HTML Code: 

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: IF, AND, DATE Syntax issue

    This is not an answer to your question but note that IF($AG49>$D$5,$AG49,$D$5) can be written as MAX($AG49,$D$5).

    Back to your question... It is difficult to diagnose a non-working formula without seeing a sample of the data that it is being used on.

    If you create and share a small representative sample of your data along with the desired result of the formula (manually entered), you will be more likely to get a result that you are happy with.

    To attach an Excel workbook, click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF, AND, DATE Syntax issue

    Also, you're way over complicating your formula.
    What is the purpose of this
    DATE(YEAR(H49),MONTH(H49),DAY(H49))
    Why deconstruct each element of the date in H49 with Year Month and Day functions, only to then reconstruct the same date with the DATE function ?
    Why not just leave the reference as H49

    And seem to do the same thing when comparing AG49 to D5

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF, AND, DATE Syntax issue

    I might also suggest posting a copy of the formula 'Before' you attempted any changes.

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF, AND, DATE Syntax issue

    I come up with this by just changing all those date manipulations back to just their cell references
    And using the MAX function FalconDude suggested

    =IF(AH49=0,0,IF(AND($D$6-H49<$AJ$10,I49="No"),ROUND((H49-MAX($D$5,$AG49)-1)/$AJ$10,2),ROUND(($D$6-MAX($D$5,$AG49)-1)/$AJ$10,2)))

    That can be further simplified with some logical thinking..

    Instead of

    =IF(A=1,Y-X,Z-X)
    Do
    =IF(A=1,Y,Z)-X

    This is a very subtle but significant difference.
    The 2nd way, I only have to reference X once.

    Applying that logic to the above formula I come up with this
    =IF(AH49=0,0,ROUND((IF(AND($D$6-H49<$AJ$10,I49="No"),H49,$D$6)-MAX($D$5,$AG49)-1)/$AJ$10,2))
    Last edited by Jonmo1; 11-14-2017 at 01:26 PM.

  6. #6
    Registered User
    Join Date
    07-31-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: IF, AND, DATE Syntax issue

    I attempted to attach the file. Please let me know if it did not come through.

  7. #7
    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
    30,741

    Re: IF, AND, DATE Syntax issue

    No file.

    Attach a sample workbook (not image).

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate.

    Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  8. #8
    Registered User
    Join Date
    07-31-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: IF, AND, DATE Syntax issue

    I believe it is attached this time?

    The cell(s) in question are in column AJ. In the "Before" in yellow on the attached the value is 1.00. The correct value is 0.89 and is in green.
    Attached Files Attached Files

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF, AND, DATE Syntax issue

    That formula is different from the one you posted.
    Very different cell references, and even sheet references (which seem unnecessary because it's a reference to the same sheet containing the formula)
    It's difficult to tell which part you want to apply this logic to IF($AG49>$D$5,$AG49,$D$5)

    And the other formula with Vlookup ? Where did that come from?

  10. #10
    Registered User
    Join Date
    07-31-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: IF, AND, DATE Syntax issue

    My apologies. I had cleaned up the sheet references, but I mistakenly went back to a version I had not edited to create the redacted version. The cell containing the Vlookup is dependent upon column AJ which is where the difficulty lies, so if column AJ is correct, column AK follows.

    As for all of the funky references and complications - I inherited the workbook and the formulas from my predecessor. He is more skilled than I when it comes to Excel, so I generally take what's there and try to "fix" it or make it work when we have changes. That being said, I obviously am not the most skilled either.

    In the end, your post prior to the last works like a charm, and I thank you! And yes, much simpler and cleaner. I can easily apply this logic to other situations in the future.

    Matt

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF, AND, DATE Syntax issue

    You're welcome.

+ 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. CUBEMEMBER() syntax issue.
    By juanss1989 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-18-2016, 09:22 AM
  2. Hyperlink Syntax Issue
    By sgrande01 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 07-10-2013, 05:27 PM
  3. syntax issue.
    By bopsgtir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2012, 09:35 PM
  4. [SOLVED] Syntax Issue
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2012, 10:36 AM
  5. .Printout syntax issue
    By rhuseman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-22-2011, 12:14 AM
  6. .Printout syntax issue
    By rhuseman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2011, 10:08 PM
  7. syntax issue
    By JT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2006, 04:10 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