Consulting

Results 1 to 10 of 10

Thread: code for determining error in s/sheet

  1. #1

    code for determining error in s/sheet

    I have a spreadsheet which contains 3 columns, such as:

    COL C COL D COL E
    ACI MEDICARE PART B UHCC
    ACI TENNCARE MEDICARE
    ACI MCR UHCC MEDICARE
    ACI MCR MEDICARE

    The "rule" is that col C should contain "ACI MCR" if EITHER columns D or E contain the word MEDICARE. If column C = "ACI MCR" and neither column D nor E contain 'MEDICARE', I need the word ERROR returned for the user. Likewise, if column D or column E do contain 'MEDICARE' and column C does not contain "ACI MCR", i need the work ERROR returned. This latter scenario is the most probable. I've tried nested if statements, using MID, AND, OR to try to achive the desired result, but can't get it to work correctly on every scenario. Here's what I currently have as a formula in 2 different columns, but need to combine them so the user only has to look for "ERROR" in one column:

    IF(MID(D1,1,8)="MEDICARE",IF(C1="ACI MCR","","ERROR"))
    IF(MID(E1,1,8)="MEDICARE",IF(C1="ACI MCR","","ERROR"))

    Thanks in advance for any help.

  2. #2
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    =IF(ISERR(SEARCH("MEDICARE",D1)),IF(ISERR(SEARCH("MEDICARE",E1)),"ERROR","A CI MCR"),"ACI MCR")

  3. #3
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    in column F : =IF(OR(AND(D1="MEDICARE";C1="ACI MCR");AND(E1="MEDICARE";C1="ACI MCR"));"";"ERROR")
    It's possible that you've got to change the ; in , in your formula.

    Charlize

  4. #4

    thanks, but didn't work

    thanks, but it didn't work. it ERRORED the record shown in attached s/sheet.

  5. #5
    thanks, but this also errored the first record as shown in the attached file. i tried changing it to the formula shown below since MEDICARE will only comprise the first 8 chars of those D and E cells, but it still failed.

    IF(OR(AND(MID(D1,1,8)="MEDICARE",C1="ACI MCR"),AND(MID(E1,1,8)="MEDICARE",C1="ACI MCR")),"","ERROR")

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =IF(OR(AND(COUNT(D1:E1,"*MEDICARE*")=0,C1<>"ACI MCR"),AND(COUNT(D1:E1,"*MEDICARE*")<>0,C1="ACI MCR")),"ERROR","ACI MCR")

  7. #7
    thanks, but that too also errored the first record as shown in attached spreadsheet and shouldn't have. does it have anything to do with not isolating the first 8 chars in D and E, or does *MEDICARE* do that?

  8. #8
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    Quote Originally Posted by pdeshazier
    thanks, but it didn't work. it ERRORED the record shown in attached s/sheet.
    if col D or col E contains the word "MEDICARE", col C should be "ACI MCR".. right?

    can you clarify, maybe i don't understand your conditions..

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    There is only one that I see. Are you saying = ACI MCR or contains ACI MCR?

    Create a sheet with all the different error conditions and a good condition.

  10. #10
    VBAX Contributor moa's Avatar
    Joined
    Nov 2006
    Posts
    177
    Location
    =IF(OR(AND(COUNTIF(D1:E1,"MEDICARE*"),C1<>"ACI MCR"),AND(NOT(COUNTIF(D1:E1,"MEDICARE*")),C1="ACI MCR")),"ERROR","")
    Glen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •