+ Reply to Thread
Results 1 to 5 of 5

Formula Does not Work

Hybrid View

  1. #1
    Registered User
    Join Date
    08-20-2009
    Location
    London
    MS-Off Ver
    Office 2019
    Posts
    28

    Formula Does not Work

    Hi,

    Could somebody please tell me why the following Vlookup is not working:

    =IF(AND(LEFT(C4,1)="W",RIGHT(C4,1)="U"),-MID(C4,2,3),IF(AND(LEFT(C4,2)="DN",LEN(C4)=4,-RIGHT(C4,2),IF(AND(LEFT(C4,2)="DN",LEN(C4)=5,-RIGHT(C4,3),IF(LEFT(C4,2)="WA",-RIGHT(C4,3),IF(LEFT(C4,2)="MC",-RIGHT(C4,3),0))))

    Where the data in column C is a 4 or 5 digit code.

    Thanks!

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Formula Does not Work

    Missing closing parentheses for the AND() functions..

    =IF(AND(LEFT(C4,1)="W",RIGHT(C4,1)="U"),-MID(C4,2,3),IF(AND(LEFT(C4,2)="DN",LEN(C4)=4,-RIGHT(C4,2)),IF(AND(LEFT(C4,2)="DN",LEN(C4)=5,-RIGHT(C4,3)),IF(LEFT(C4,2)="WA",-RIGHT(C4,3),IF(LEFT(C4,2)="MC",-RIGHT(C4,3),0)))))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

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

    Re: Formula Does not Work

    You're missing a few parentheses. I believe it should read
    =IF(AND(LEFT(C4,1)="W",RIGHT(C4,1)="U"),-MID(C4,2,3),IF(AND(LEFT(C4,2)="DN",LEN(C4)=4,-RIGHT(C4,2)),IF(AND(LEFT(C4,2)="DN",LEN(C4)=5,-RIGHT(C4,3)),IF(LEFT(C4,2)="WA",-RIGHT(C4,3),IF(LEFT(C4,2)="MC",-RIGHT(C4,3),0)))))
    Does that work for you?
    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

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Formula Does not Work

    Try this...

    =-IF(COUNTIF(C4,"W???U"),MID(C4,2,3),IF(OR(LEFT(C4,2)={"DN","WA","MC"}),MID(C4,3,3),0))

  5. #5
    Registered User
    Join Date
    08-20-2009
    Location
    London
    MS-Off Ver
    Office 2019
    Posts
    28

    Smile Re: Formula Does not Work

    Brilliant!

    Thanks all for the suggestions.

    You really know your stuff!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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