+ Reply to Thread
Results 1 to 9 of 9

if statement to find a number and return that number in a cell

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    4

    if statement to find a number and return that number in a cell

    Hi,

    I have this scenario below, in column A I have the descriptions and in column B I would like it to look up column A and find "2P" or "3P" and return just the numerical value in column B. I have tried with "if" and "right" statements but I cannot seem to get it right. The purpose of this exercise is just to find out how many packs are in each of the styles (ignoring the 90ml/3oz sizes, if possible). Thanks for your assistance.

    A B
    1 Everyday Pants 2P
    2 Everyday Pants 3P
    3 Shape Sleek Short
    4 Silhouette Pants
    5 Soak Bottle 90mL/3oz
    6 Everyday Pants 4P

    Regards,
    Neelam

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: if statement to find a number and return that number in a cell

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: if statement to find a number and return that number in a cell

    Thanks vlady. But this forumla did not work

  4. #4
    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,929

    Re: if statement to find a number and return that number in a cell

    Hi and welcome to the forum

    a cpl of questions for you...
    1. what is not working? please explain what results you are getting and what results you were expecting.
    2. what data is in column A and what is in column B - your sample data is not that clear. i would suggest you upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    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

  5. #5
    Registered User
    Join Date
    05-07-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: if statement to find a number and return that number in a cell

    Hi,

    The result was blank. I have attached the example file.

    Thank you.
    Attached Files Attached Files

  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,929

    Re: if statement to find a number and return that number in a cell

    thanks.

    Try this, copied down..
    =IFERROR(MID(A2,SEARCH("2P",A2,1),1),IFERROR(MID(A2,SEARCH("3P",A2,1),1),""))
    if you want the answer to be a value instead of text, use this...
    =IFERROR(MID(A2,SEARCH("2P",A2,1),1)*1,IFERROR(MID(A2,SEARCH("3P",A2,1),1)*1,""))

  7. #7
    Registered User
    Join Date
    05-07-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: if statement to find a number and return that number in a cell

    Thank you. That worked perfect.

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: if statement to find a number and return that number in a cell

    sorry bout that my bad, the typo on my part in "P@" just to correct my given formula.

    =IFERROR(LEFT(TRIM(RIGHT(SUBSTITUTE(A2&"@"," ",REPT(" ",LEN(A2&"@")-1)),LEN(A2&"@"))),FIND("P@",TRIM(RIGHT(SUBSTITUTE(A2&"@"," ",REPT(" ",LEN(A2&"@")-1)),LEN(A2&"@"))))-1)*1,"")

    this will get the value regardless of what is the numeric value before the P character. say 500P , 23P, etc.

    Thanks.

  9. #9
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: if statement to find a number and return that number in a cell

    Try my formula. It will work either the "numeric +P" in front, in the middle, or at the end. See the attached
    Attached Files Attached Files

+ 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