+ Reply to Thread
Results 1 to 10 of 10

Find String in one Column with Condition in Another Column

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Find String in one Column with Condition in Another Column

    Hi all,

    When I used the following formula:

    HTML Code: 
    HTML Code: 
    it returns 1. However, I need row 3 – the one with the smallest number in column A. Any help?

    Thanks,
    Gos-C
    Using Excel 2010 & Windows 10
    "It is better to be prepared for an opportunity and not have one than to have an opportunity and not be prepared."

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Find String in one Column with Condition in Another Column

    The content of column A is not a number, it's text. How do you define "smallest"? From a text point of view your example is sorted in lowest-to-highest order, so row 1 does have the smallest value.

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,957

    Re: Find String in one Column with Condition in Another Column

    IF by smallest you mean the value of the third set of digits, then with your table in columns A to C, in D2 enter the formula

    =VALUE(MID(A2,FIND("-",A2,FIND("-",A2)+1)+1,LEN(A2)))

    Copy that down to match your list. Then use this array-entered formula, entered using Ctrl-Shift-Enter:

    =SUM(IF(NOT(ISERROR(FIND("ACETYL-L-CYSTEINE",C2:C1000))),IF(D2:D1000=MIN(IFERROR(VALUE(MID(A2:A1000,FIND("-",A2:A1000,FIND("-",A2:A1000)+1)+1,LEN(A2:A1000))),100000)),ROW(A2:D1000))))

    This assumes that the combinations of numbers and names are unique....
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Find String in one Column with Condition in Another Column

    Thank you very much for your replies. Yes, Bernie's assumption is correct, and his formulas worked perfectly on the sample table that I provided. However, I can't figure out why the 2nd and main formula is not working on my full table (which has 3296 rows), even though I changed the ranges last row in the formula to 3296 and entered using Ctrl-Shift-Enter. It is returning 0.

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,957

    Re: Find String in one Column with Condition in Another Column

    Works for me - here is my test workbook. Make sure that your data has no dupes, errors, or blanks. If you could upload a version that shows that behavior
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Find String in one Column with Condition in Another Column

    Hi Bernie,

    Please find the file attached.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,957

    Re: Find String in one Column with Condition in Another Column

    Array enter

    =SUM(IF(NOT(ISERROR(FIND("ACETYL-L-CYSTEINE",C2:C3296))),IF(D2:D3296=MIN(IF(NOT(ISERROR(FIND("ACETYL-L-CYSTEINE",C2:C3296))),IFERROR(VALUE(MID(A2:A3296,FIND("-",A2:A3296,FIND("-",A2:A3296)+1)+1,LEN(A2:A3296))),100000))),ROW(A2:D3296))))

  8. #8
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Find String in one Column with Condition in Another Column

    Hi Bernie,

    Thanks for the modified formula. I really appreciate your help. There were still some issues with it though; It was returning some weird results (the row number was outside the data range) for some search items. I figured it out: it was because of seemingly duplicates. So I concatenated C with its description from another column and used it instead of C.

    Also, I need to modify the formula to extract the unit size (i.e., 250, 120,500 etc.) as well, from the following:

    [HTML][/55-2303-250 MG
    30-4399-U120
    55-4475-500 MG
    23-1012-100 MG
    24-2986-100 MG
    55-2627-500 MG
    30-1419-500 MG
    55-1714-500 MG
    20-1019-100 MG
    20-1019-500 MG
    55-1794-500 MG
    30-1705-200 MG
    30-2185-250 MG
    55-2692-1080 MG
    55-2692-540 MG
    55-1877-250 MG
    30-2963-500 MG
    50-3512-500 MG
    20-3213-10 MG
    20-3213-100 MG
    35-1576-25B
    35-1576-25P
    35-2127-25B
    35-2127-25P
    HTML]

    Thanks

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Find String in one Column with Condition in Another Column

    For extract the unit size, Data in column A
    B2 copy down

    =IFERROR(LOOKUP(9^9,--MID(A2,9,{1,2,3,4,5,6})),LOOKUP(9^9,--RIGHT(MID(A2,9,5),{1,2,3,4,5})))
    Last edited by Bo_Ry; 10-21-2018 at 01:12 AM. Reason: for 5 digit number

  10. #10
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Find String in one Column with Condition in Another Column

    Great! Thank you, thank you, thank you very much, Bo_Ry.

+ 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] Find a string in column A and multiply x into corresponding value in column B
    By anujv22 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-19-2016, 08:03 PM
  2. Replies: 4
    Last Post: 03-30-2015, 03:20 PM
  3. [SOLVED] To Find if a text string contains key words in column B and C and set to value in column D
    By alice2011 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-27-2015, 11:42 AM
  4. [SOLVED] Find name in Column E then count string in Column B
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-11-2013, 09:32 PM
  5. Replies: 12
    Last Post: 12-28-2012, 07:49 PM
  6. [SOLVED] Find string in Column A then verify Date in Column B
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-17-2012, 07:13 PM
  7. how to find Certain String in a column, select/Copy the cell till another String
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2009, 10:59 AM

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