+ Reply to Thread
Results 1 to 11 of 11

IF AND Statement Issue?

  1. #1
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Unhappy IF AND Statement Issue?

    Hello!

    Trying to get this if statement to work,

    =IF(AND LEFT(A2,1)="L", LEFT(A2,2)="V"),Z2="Furniture", IF(AND LEFT(A2,1)="D",LEFT(A2,2)="E"),Z2="Decor",IF(AND LEFT(A2,1)="D", LEFT(A2,2)="N"),Z2="Furniture", IF(AND LEFT(A2,1)="B", LEFT(A2,2)="D"),Z2="Bed",IF(AND LEFT(A2,1)="L", LEFT(A2,2)="T"),Z2="Lighting", IF(AND LEFT(A2,1)="B" ,LEFT(A2,2)="A"),Z2="Bath", IF(AND LEFT(A2,1)="K" ,LEFT(A2,2) = "T"), Z2 = "Kitchen", IF(AND LEFT(A2,1)="H",LEFT(A2,2) = "W"), Z2 = "Hardware", IF(AND LEFT(A2,1)="F", LEFT(A2,2) = "L"), Z2 = "Flooring", Z2 = "NOPE")))))))))

    So, IF the first letter in cell A2 is "L" AND the second letter in cell A2 is "V" then Z2 should equal "Furniture" in its cell.

    I think I'm missing bracket or a comma or something silly, if you guys can please let me know what I need to do to get this working that would be awesome!
    Last edited by Vaibhav; 05-17-2016 at 03:30 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: IF AND Statement Issue?

    If you require this formula in Z2 then perhaps

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    However have you thought about a lookup table and using a VLOOKUP?

    Upload the workbook for more specific advice and manually add some typical results so we know exactly what you want.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    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,209

    Re: IF AND Statement Issue?

    I think you need something like ..

    =IF(LEFT(A3,2)="LV","Furniture",IF(LEFT(A3,2)="DE,"Decor", ........

    Comparing first two characters ...???

  4. #4
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: IF AND Statement Issue?

    I managed to figure it out with the info you guys provided.

    here is the final statement

    =IF(LEFT(A2,2)="LV","Furniture",IF(LEFT(A2,2)="DE","Decor",IF(LEFT(A2,2)="DN","Furniture",IF(LEFT(A2,2)="BD","Bed",IF(LEFT(A2,2)="LT","Lighting",IF(LEFT(A2,2)="BA","Bath",IF(LEFT(A2,2)="KT","Kitchen",IF(LEFT(A2,2)="HW","Hardware",IF(LEFT(A2,2)="FL","Flooring","")))))))))

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF AND Statement Issue?

    Create a 2 column table like this:

    Data Range
    E
    F
    1
    ------
    ------
    2
    LV
    Furniture
    3
    DE
    Decor
    4
    DN
    Furniture
    5
    BD
    Bed
    6
    LT
    Lighting
    7
    BA
    Bath
    8
    KT
    Kitchen
    9
    HW
    Hardware
    10
    FL
    Flooring


    Then the formula would be:

    =IFERROR(VLOOKUP(LEFT(A2,2),E2:F10,2,0),"")

    EDIT...test
    Last edited by Tony Valko; 05-17-2016 at 02:37 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    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
    52,938

    Re: IF AND Statement Issue?

    Nice

    You could probably condense that a little by using OR...
    =IF(ORLEFT(A2,2)="LV",LEFT(A2,2)="DN"),"Furniture",........................
    (may be others you can combine too.

    hmm alternatively, a small table with the LEFT 2 characters in 1 column, and their "word" in the next, then use VLOOKUP()...
    A
    B
    C
    2
    LV123
    3
    LV Furniture Furniture
    4
    DE Décor
    5
    DN Furniture
    6
    BD Bed
    7
    LT Lighting
    8
    BA Bath

    etc
    C3=VLOOKUP(LEFT(A2,2),$A$3:$B$8,2,0)
    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

  7. #7
    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
    52,938

    Re: IF AND Statement Issue?

    hmm interesting, I tried to edit my post, and got a blank "entry" screen, was going to say to Tony that GMTA

    Tony what happens if you try to edit your post?

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF AND Statement Issue?

    Quote Originally Posted by FDibbins View Post
    Tony what happens if you try to edit your post?
    I was able to edit my post.

  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
    28,209

    Re: IF AND Statement Issue?

    @Ford,
    On several occasions I too have had the "blank" screen when trying to edit an earlier post: no obvious reason as to why it happens.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: IF AND Statement Issue?

    Quote Originally Posted by legnak View Post
    I managed to figure it out with the info you guys provided.
    My pleasure to have assisted and thanks for the rep.

  11. #11
    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
    52,938

    Re: IF AND Statement Issue?

    I still get the blank "typing" window

+ 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] If Statement Issue
    By mansions2find in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-24-2015, 10:53 AM
  2. if statement issue
    By headford in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-08-2013, 12:30 PM
  3. Issue with IF statement
    By DennyMathews in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-09-2012, 10:06 AM
  4. in between #...issue if statement
    By jw01 in forum Excel General
    Replies: 7
    Last Post: 06-29-2011, 11:04 AM
  5. if statement issue
    By jw01 in forum Excel General
    Replies: 7
    Last Post: 05-27-2011, 01:16 PM
  6. If statement issue
    By punter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2008, 10:15 AM
  7. If statement issue
    By punter in forum Excel General
    Replies: 3
    Last Post: 11-27-2006, 04:39 PM

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