+ Reply to Thread
Results 1 to 12 of 12

Errors with codes/formulas - Beginner mistake?

  1. #1
    Registered User
    Join Date
    06-24-2015
    Location
    South of UK
    MS-Off Ver
    2013
    Posts
    6

    Errors with codes/formulas - Beginner mistake?

    Hello All,

    I consider myself lightly experienced in coding. I haven't been using "complex" Excel formulas for long so the below is probably a rookie error.
    I am having an issue with the below formula:

    This formula works:
    =IF(ISBLANK(D197),"N/A",IF(D197="open",TODAY()-G197,"CLOSED"))

    but when I want to add the function to make the cell in question display "ON HOLD" if cell D197 displays "ON HOLD", I only get the result: "CLOSED", even if cell D197 reads "ON HOLD".

    =IF(ISBLANK(D198),"N/A",IF(D198="open",TODAY()-G198,IF(D198="ON HOLD","ON HOLD","CLOSED")))

    Where is my mistake?
    Is there an easier way of doing this all together?

    Cheers guys,

    JM

  2. #2
    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,862

    Re: Errors with codes/formulas - Beginner mistake?

    Possible data problem e.g. extra space in "ON hold" i.e.. " ON hold". Use TRIM function to remove unwanted blanks

  3. #3
    Registered User
    Join Date
    06-24-2015
    Location
    South of UK
    MS-Off Ver
    2013
    Posts
    6

    Re: Errors with codes/formulas - Beginner mistake?

    I have triple checked the data, no anomalies found. I also tried the TRIM function but with no success.
    Thanks for the suggestion though!
    Any other ideas?

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Errors with codes/formulas - Beginner mistake?

    Can you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.

    Maybe a typo, but you say...
    if cell D197 displays "ON HOLD", I only get the result: "CLOSED", even if cell D197 reads "ON HOLD".
    yet your formula is referencing D198?
    Last edited by FDibbins; 06-26-2015 at 12:37 AM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    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,862

    Re: Errors with codes/formulas - Beginner mistake?

    Re-post please

    try for INDEX problem

    =IFERROR(INDEX($B$2:$B$9, SMALL(IF(VALUE($A$13)=VALUE($A$2:$A$9), ROW($A$2:$A$9)-ROW($A$2)+1), ROW(1:1))),"")

  6. #6
    Registered User
    Join Date
    06-24-2015
    Location
    South of UK
    MS-Off Ver
    2013
    Posts
    6

    Re: Errors with codes/formulas - Beginner mistake?

    Hello Ford,
    That is indeed a typo. All cells referenced should read D197.
    I have attached a version of the document with pretty much all of the fat trimmed away. The blue cells are the cells that change from line to line, the yellow cells are the cells containing the formulas in question. Row 7 shows the expected result.
    I hope this is enough info!

    Regards,
    James
    Attached Files Attached Files

  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,862

    Re: Errors with codes/formulas - Beginner mistake?

    See attached: testing on column C (?)

    I just copied your formula and changed D197 to C7
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    06-24-2015
    Location
    South of UK
    MS-Off Ver
    2013
    Posts
    6

    Re: Errors with codes/formulas - Beginner mistake?

    Hi John,

    Thanks very much for your help & Advice here.
    Your formula does indeed work, it seems when making the "formula-practice" document, I overlooked some incorrect cell references (This is why I titled this thread 'beginner mistake?' ").
    When I copy your working formula into the main document, I still get the same error. I'm now thinking that this is an error with Excel 2013 or my PC.

    So, just to clarify, the formula works when taken out of the document, but won't work (Returns "Closed", Instead of "on Hold") inside the document.

    At least I can rest easy knowing my formulas are ok (with maybe some cell reference errors). Luckily, this formula is not overly important and only helps with a layout issue. This is something that can be worked around.

    Thanks again all,

    James

  9. #9
    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,862

    Re: Errors with codes/formulas - Beginner mistake?

    Is it possible to send an extract of the "erroneous" file where the error is occurring? It is such a simple formula so it is difficult to understand why it does work.

    I know it is very basic but check the cell has no extraneous blanks i.e " ON HOLD"

    Try this

    =IF(ISBLANK(C4),"N/A",IF(C4="open",TODAY()-E4,IF(TRIM(C4)="ON HOLD","ON HOLD","CLOSED")))

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Errors with codes/formulas - Beginner mistake?

    There can only be two possibilities.
    Either you are referencing the wrong cell, which you say you aren't,
    or the "On Hold" in C4 is not the same as your "On Hold" in your formula.

    Try this.
    Type On Hold into a blank cell (let's say G4)
    then in another cell
    =C4=G4
    It should return TRUE.
    If not, then do =LEN(C4), that should return 7
    This narrows down where your problem is.
    TRIM does not necessarily work for all invisible characters.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  11. #11
    Registered User
    Join Date
    06-24-2015
    Location
    South of UK
    MS-Off Ver
    2013
    Posts
    6

    Re: Errors with codes/formulas - Beginner mistake?

    Hello All,

    I am very happy to say that John Topley, you TRIM function addition works a charm. Thank you very much. Unfortunately, I can't really send a fragment of the document due to it's confidential nature.

    ChemistB,
    I did a "Len" test on both cells in the document, the cell from row D in my main document returned a length of 8, while the other "On Hold" returned a 7 as to be expected.
    There must be a hidden character in there somewhere. I'm unsure where and It's for sure not visible to the standard user. I have re-typed "On Hold" into both of those cells countless times.

    I had given up on this formula, thanks for sticking with this thread!

  12. #12
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Errors with codes/formulas - Beginner mistake?

    To find the identity of the hidden character in D4
    In an empty cell
    =CODE(MID($D$4,COLUMNS($A$1:A$1,1))
    and copy it to the right.
    You should get
    79 110 32 72 111 108 100

    Report any unusual code and someone here can tell you what it is.

+ 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] Clear All VBA Codes and formulas
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-03-2014, 04:04 PM
  2. Using Formulas to Generate SKU codes
    By X-tremejoe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2013, 03:55 PM
  3. Using Formulas to Generate SKU codes
    By X-tremejoe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2013, 03:33 PM
  4. Creating VBA codes to do what formulas do
    By jacglc2010 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2010, 01:52 PM
  5. Beginner(formulas?)
    By nomad31 in forum Excel General
    Replies: 3
    Last Post: 08-29-2005, 07:05 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