+ Reply to Thread
Results 1 to 4 of 4

Need help with if statement and 3 conditions

  1. #1
    Forum Contributor
    Join Date
    07-06-2009
    Location
    London, England
    MS-Off Ver
    Microsoft 365
    Posts
    184

    Need help with if statement and 3 conditions

    I am extracting data within a cell. 3 conditions apply

    condition1 =MID(B2,FIND("condition1",B2)+28,(FIND(",",B2)-(FIND("condition1",B2)+28)))
    condition2 =MID(B2,FIND("condition2",B2)+28,(FIND(",",B2)-(FIND("condition2",B2)+28)))
    condition3 =MID(B2,FIND("condition3",B2)+28,(FIND(",",B2)-(FIND("condition3",B2)+28)))

    This is my non-working if statement, but Excel keeps telling me I have entered too few arguments:

    =if(MID(B2,FIND("condition1",MID(B2,FIND("condition1",B2)+28,(FIND(",",B2)-(FIND("condition1",B2)+28)))))),MID(B2,FIND("condition1",MID(B2,FIND("condition1",B2)+28,(FIND(",",B2)-(FIND("condition1",B2)+28))))),if(MID(B2,FIND("condition3",MID(B2,FIND("condition3",B2)+28,(FIND(",",B2)-(FIND("condition3",B2)+28)))))),MID(B2,FIND("condition3",MID(B2,FIND("condition3",B2)+28,(FIND(",",B2)-(FIND("condition3",B2)+28))))),IF(MID(B2,FIND("condition2",MID(B2,FIND("condition2",B2)+28,(FIND(",",B2)-(FIND("condition2",B2)+28)))))),MID(B2,FIND("condition2",MID(B2,FIND("condition2",B2)+28,(FIND(",",B2)-(FIND("condition2",B2)+28))))),"No data available")

    I can't see the wood for the trees. Can someone help me? Thanks.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,683

    Re: Need help with if statement and 3 conditions

    Yikes!

    There's probably a much easier way of doing what you are trying to do. Explain (in words) what that is and attach your workbook here.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: Need help with if statement and 3 conditions

    Hi
    why cant you FIND only "condition" (instead of Condition1, Condition2, Condition3)

    this too will give you the same result
    =MID(B2,FIND("condition",B2)+28,(FIND(",",B2)-(FIND("condition",B2)+28)))

  4. #4
    Forum Contributor
    Join Date
    07-06-2009
    Location
    London, England
    MS-Off Ver
    Microsoft 365
    Posts
    184

    Re: Need help with if statement and 3 conditions

    Thanks for the replies folks.
    It's a new dawn it's a new day, and with a fresh mind and Sadath's code I came up with a simplified version of the if statement which uses a helper column to find the first condition. I should point out that I am writing from work and our firewall does not allow me to submit the exact wording of the conditions which are varied length of html tags, but for illustrative purposes here is a simplified version of the working code.

    Helper column (G2)
    Please Login or Register  to view this content.
    Event column (E2)
    Please Login or Register  to view this content.
    Thanks for your advice and help

+ 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. Replies: 2
    Last Post: 07-09-2015, 04:25 PM
  2. 3 Conditions for an IF Statement
    By Rocksteady in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-21-2013, 07:38 AM
  3. if statement with two conditions
    By mkmed in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-03-2007, 09:49 PM
  4. Two conditions in one IF statement
    By shashi1515 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2006, 04:10 PM
  5. why can i use 3 conditions in SQL statement only?
    By Tarek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2005, 03:05 AM
  6. Replies: 3
    Last Post: 06-26-2005, 10:05 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