+ Reply to Thread
Results 1 to 8 of 8

IF Statement

  1. #1
    Registered User
    Join Date
    08-27-2014
    Location
    UK
    MS-Off Ver
    office 2010
    Posts
    6

    IF Statement

    I have a spreadsheet with various columns. One column is the “Category” field and another one is the “Description” field.
    Where the category field says “Sales” the description field has content made up of a few elements and I want to separate the elements into other fields named Reference1, Reference2, Reference3 and Referance4.

    The description field is something like this

    Item - Ford Part Number - 1234 Customer Number – XXX111 Customer Name – JB

    In the Reference1 field I need something like where IF the category = “Sales” I want the “Item” to appear in Reference1 else Reference1
    In the Reference2 field I need something like where IF the category = “Sales” I want the “Part Number” to appear in Reference2 else Reference2
    The same for Reference3 and Reference4.

    I do not know how to split out the description into the separate parts.

    Can anyone help please? Thanks

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: IF Statement

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    08-27-2014
    Location
    UK
    MS-Off Ver
    office 2010
    Posts
    6

    Re: IF Statement

    Please find attached sample workbook. It has a Before and After sheets. Thanks
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: IF Statement

    Copy and Paste the formula

    C2:
    Please Login or Register  to view this content.
    D2:
    Please Login or Register  to view this content.
    E2:
    Please Login or Register  to view this content.
    F2:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-27-2014
    Location
    UK
    MS-Off Ver
    office 2010
    Posts
    6

    Re: IF Statement

    Hi Thanks for the this but does not work for me because not all the rows will the category of Sales as per the example workbook I attached. So I will need some sort of an IF statement to say IF category = "Sales",...................

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: IF Statement

    Why can't you use the texts to columns function with the " - " as the delimiter?

  7. #7
    Registered User
    Join Date
    08-27-2014
    Location
    UK
    MS-Off Ver
    office 2010
    Posts
    6

    Re: IF Statement

    Quote Originally Posted by Sc0tt1e View Post
    Why can't you use the texts to columns function with the " - " as the delimiter?
    Because the description is like this for only where the category is "Sales" and just the description for this category needs splitting.

  8. #8
    Registered User
    Join Date
    10-27-2014
    Location
    Minnesota
    MS-Off Ver
    2013
    Posts
    12

    Re: IF Statement

    If the formulas provided by dluhut return the values you expect, simply wrap the entire formula in an IF statement.

    This would make the formula in C2 : =IF(A2="Sales",MID($B2,FIND("Item - ", $B2)+7, FIND("Part Number - ",$B2)-1-FIND("Item - ", $B2)-7),"")

    Be warned that if anything gets changed in the Description column for the Sales data the formulas will break. (If "Part Number" somehow gets an extra space, or a double dash is added, for example). Also, depending on how data is getting entered, you may want to use a helper sheet to gather data for all "Sales" entries, and another to input data for "Purchases" entries. Then combine the two after the fact.

+ 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. [SOLVED] If statement to select data - nested statement - assistance
    By petitesouris in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-29-2015, 09:55 PM
  3. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  4. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  5. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  6. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  7. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 PM

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