+ Reply to Thread
Results 1 to 11 of 11

Search a column and insert a code in a different column based on the finding in each row.

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    West Byfleet, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Search a column and insert a code in a different column based on the finding in each row.

    Hi Guys

    Hoping someone can help and hoping this makes sense.

    Every week I receive a worksheet with around 50 different transactions on it under the column(B) heading "Description". I run a sort and then insert a code in column E.

    E.g. If the description in column B = Test account, the code in column E = P. Also, If the description in column B = sterling fee, the code in column E = V ......etc etc.

    I want an IF statement or something to search the whole of column B and code column E appropriately in the same row.
    I realize I will need to write all the 50 or so different options that the statement needs to look for but can anyone help with the basics please? Ideally I would write a list that can be searched and that I can add to at any time.

    Andrew
    Last edited by redoscar; 08-04-2016 at 08:04 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Search a column and insert a code in a different column based on the finding in each r

    make life simpler for yourself...

    On another sheet, set up your table and use a simple INDEX-MATCH

    =IFERROR(INDEX(Sheet2!B:B,MATCH(Sheet1!B2,Sheet2!$A$1:$A$5,0)),"")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    09-05-2012
    Location
    West Byfleet, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Search a column and insert a code in a different column based on the finding in each r

    Glenn

    Thank you so much for this. Simple to you but difficult for me. Will save me a couple of hours.

    Thank You

    Andrew

  4. #4
    Registered User
    Join Date
    09-05-2012
    Location
    West Byfleet, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Search a column and insert a code in a different column based on the finding in each r

    Hi Glenn

    I was wondering if there was a way to search the string for a partial match within this formula?

    Regards

    Andrew

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Search a column and insert a code in a different column based on the finding in each r

    Hmm. i thought I had posted a Q about this... but my phone seems to have lost it. can you describe EXACTLY what you mean when you say partial match? I suspect that you're asking an entirely different question....

  6. #6
    Registered User
    Join Date
    09-05-2012
    Location
    West Byfleet, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Search a column and insert a code in a different column based on the finding in each r

    Hi Glenn

    Please Login or Register  to view this content.
    =IFERROR(INDEX('Code List'!B:B,MATCH(Out!B2,'Code List'!$A$1:$A$5000,0)),"")
    Please Login or Register  to view this content.
    This code words perfectly if I am looking for a perfect match. Is there a way of looking for matches with slight variations.

    e.g.
    20-Jun-16 INT'L 0003120948 Uber BV help.uber.com 4.7
    20-Jun-16 INT'L 0003120949 Uber BV help.uber.com 10.37

    These 2 entries are slightly different. Instead of having to match them perfectly, I would like the code to match anything with Uber in it and give it a code Z.

    Does this make sense?

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Search a column and insert a code in a different column based on the finding in each r

    Not tested extensively, but this seems OK...

    =IFERROR(INDEX(Sheet2!$B$1:$B$5,SMALL(IF(IF(ISERROR(SEARCH(Sheet2!$A$2:$A$5,Sheet1!B2)),FALSE,TRUE),ROW(Sheet2!$B$2:$B$5)),1)),"")

    Array entered.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-05-2012
    Location
    West Byfleet, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Search a column and insert a code in a different column based on the finding in each r

    Thanks Glenn

    Can you tell me what { } are at the beginning and end of the code? When I try to add a new Phrase & Code (extend from $B$1:$B$5 to say $B$1:$B$500) these { } disappear . If I try to add them again, it just shows the code as text.

    Sorry for all these questions Glenn.

    Andrew

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Search a column and insert a code in a different column based on the finding in each r

    Ah sorry.. They are array formulae.

    Array Formulae are a little different from ordinary formulas in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    You will know the array is active when you see curly braces { } appear around the outside of your formula. If you do not CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly braces yourself - it won't work...

  10. #10
    Registered User
    Join Date
    09-05-2012
    Location
    West Byfleet, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Search a column and insert a code in a different column based on the finding in each r

    Glenn

    This seems to all be working great.

    Thank you so much for your time and help.

    Best Regards

    Andrew

  11. #11
    Registered User
    Join Date
    09-05-2012
    Location
    West Byfleet, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Search a column and insert a code in a different column based on the finding in each r

    Glenn

    This seems to all be working great.

    Thank you so much for your time and help.

    Best Regards

    Andrew

+ 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] Search a column for up to 30 words then insert a different word in a separate column
    By SFore in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-18-2014, 05:13 PM
  2. [SOLVED] the code is finding repeated values but i need to search values from E column to D
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-14-2014, 01:33 AM
  3. Code to hide columns based on date criteria and insert another column with formulas
    By RandiLee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 11:04 AM
  4. Search in every column for a value in a specific row, then insert a column before if match
    By manueslapera in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2012, 04:48 PM
  5. Finding a column value based on date and column header
    By soready42012 in forum Excel General
    Replies: 0
    Last Post: 01-18-2012, 06:21 PM
  6. Macro to search column with last value and insert TOTAL column to the left
    By sbara906 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-02-2009, 11:34 AM
  7. Replies: 1
    Last Post: 05-02-2008, 04:57 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