+ Reply to Thread
Results 1 to 5 of 5

If cell contains ValueA then insert ValueB then next

  1. #1
    Registered User
    Join Date
    09-27-2018
    Location
    Spain
    MS-Off Ver
    2016
    Posts
    2

    If cell contains ValueA then insert ValueB then next

    Dear all,

    I am working on a project to easily assign requests to team members depending on keywords. I haven't coded loops in VBA for quite a while and am a little rusty, hence I would need some help!

    I want to program an "auto assignment" macro based on pre-established criterias.

    On Tab 1 - the criterias to be used (team member in charge of...)
    On Tab 2 - the data I want to assign to each team member

    tab1.PNG

    tab2.PNG

    For each items in Tab 2 colomn B - I would like the macro the run all possibilities :

    - For Tab2 B2 : if B2 contains Tab1 B2 > insert Tab1 A2 in Tab2 A2
    if not > if B2 contains Tab1 B3 > insert Tab1 A3 in Tab2 A2
    if not > if B2 contains Tab1 B4 > insert Tab1 A4 in Tab2 A2

    > If a matching keyword is found; move to next line item (B3)
    > If the description does not contains any matching keywords; insert nothing and move to next line item (B3)

    In the end, Tab 2 should be filled as follow :

    tab2result.PNG

    Many thanks in advance for helping me making this macro !

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: If cell contains ValueA then insert ValueB then next

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.


    To add a file to a post

  3. #3
    Registered User
    Join Date
    09-27-2018
    Location
    Spain
    MS-Off Ver
    2016
    Posts
    2

    Re: If cell contains ValueA then insert ValueB then next

    Attached sample file + expected result tab.

    I also added a criteria for the search; the team number (1 or 2)
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: If cell contains ValueA then insert ValueB then next

    See next code
    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  5. #5
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: If cell contains ValueA then insert ValueB then next

    Hi Malotrue!

    First of all I know you asked for a VB solution, and PCI provided one for you. I got also a formula solution. In my practice, I always use VBA if I cannot use formula first. Formulas are known to be faster and not so resource consuming. So there it is, paste it on Tab2 cell A2 using CTRL+SHIFT+ENTER (not just ENTER) and fill it down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by bulina2k; 12-02-2018 at 02:28 PM. Reason: update formula to accommodate the Team column also
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

+ 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. Vba that moves cells with text, (up and to left, insert row/ insert copied cell)
    By sergi117 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2018, 03:12 PM
  2. Replies: 5
    Last Post: 08-30-2017, 01:52 PM
  3. IF "text" present with valueA >0, return valueB matching "text"
    By Raffen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-26-2015, 10:06 AM
  4. [SOLVED] Macro to insert row if cell(i,1) notequal cell(i,1)+1 and insert certain values in row.
    By mareike in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-16-2013, 03:29 AM
  5. After insert new record, insert values in row based on first cell in row
    By frankienap in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2012, 11:36 AM
  6. Replies: 11
    Last Post: 06-01-2009, 09:12 PM
  7. Replies: 2
    Last Post: 02-20-2006, 10:40 AM

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