+ Reply to Thread
Results 1 to 10 of 10

VBA to record multiple string search occurence in range

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    VBA to record multiple string search occurence in range

    Hi All

    I need guidance as to which procedure to use for the following problem...
    I have uploaded a sample file consisting of:

    Sheets("Customer Listing")
    Sheets("Customer Sales")
    Sheets("Product Breakdown Description")
    Sheets("Product Breakdown")

    Sheets("Product Breakdown Description") contains the following headers with each having there own search criteria in rows below.
    Alcohol,Chillbev,Energy,Generic,Penbev,Craft,Other

    I need to search Sheets("Customer Sales").Range("A")
    For the "ACTIVE" Customers from Sheets("Customer Listing").Range("A")
    And Find all occurrences of Sheets("Product Breakdown Description") within
    Sheets("Customer Sales").Range("B")
    And record the occurrences in Sheets("Product Breakdown") under the appropriate headers.

    My mock up depicts in Sheets("Customer Sales") all products highlighted(for reference only)with there particular color dependent on the type of Header....
    and I've merged column C to show same product occurrences that count as 1 only.

    So basically if a product is listed in the particular clients sales which falls under the particular Headers search criteria then the count is 1, if it is a duplicate then the count is still 1.


    Sheets("Product Breakdown") currently has the required result.
    Any guidance will be appreciated.
    My code thus far only populates the active client list in Sheets("Product Breakdown")

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 05-22-2017 at 05:15 AM. Reason: Updated code
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA to record multiple string search occurence in range

    ..................Deleted.....................
    Last edited by sintek; 05-20-2017 at 06:52 AM.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA to record multiple string search occurence in range

    This code works but can be simplified I'm sure....

    Please Login or Register  to view this content.


    EDITED:

    Have managed to come up with the above code that fulfills my requirement....
    Last edited by sintek; 05-20-2017 at 07:57 AM. Reason: Changed code

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to record multiple string search occurence in range

    no time before tomorrow, then i see to it

    Kind regards
    Leo

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA to record multiple string search occurence in range

    Thanks Leo for your response....See amended code in post 3 which works.....
    Could be simplified I'm sure...
    Last edited by sintek; 05-20-2017 at 07:56 AM.

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to record multiple string search occurence in range

    Hi Sintek,

    i sheet Customer Sales i made some remarks why some products
    will appear in different category


    Kind regards
    Leo
    Attached Files Attached Files

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA to record multiple string search occurence in range

    Hi LeoTaxi

    Absolutely love the simplified code....Thanks so much...
    Noticed your notes...my keywords are gonna cause errors of course.
    The SP is the keyword for this product range...SP LIMONATA LATTINA X24, SP MELOGRANO X24 ETC
    Any workaround for this or must I get my client to change there product descriptions.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA to record multiple string search occurence in range

    I just can't wrap my head around it....What I want to do is put All the SP Flavours in an array and if any of them are found in sales then the count must be 1 only.

  9. #9
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to record multiple string search occurence in range

    Maybe you can put a space after keyword SP ?

    Kind regards
    Leo

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA to record multiple string search occurence in range

    That will solve the problem, however, i just realized that there are a few other discrepancies with this keyword method....Am going to open a new post with a small example to see if we can solve this....Thanks again for your time Leo.

+ 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. SUMPRODUCT & SEARCH - multiple string search
    By rodgersmg in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-10-2015, 05:14 AM
  2. search for a string in cell having multiple string
    By sandhya16 in forum Excel General
    Replies: 5
    Last Post: 07-03-2015, 03:51 AM
  3. [SOLVED] Help with macro to search and record from multiple worksheets
    By Lockheed in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-03-2015, 02:10 PM
  4. simple macro to add new record, edit/ search and print record
    By xmoore in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2015, 08:10 PM
  5. SEARCH FOR LAST MATCHING OCCURENCE IN Wb2, PASTE RANGE OF CELLS BACK TO Wb1
    By excelnat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2014, 06:52 AM
  6. [SOLVED] multiple record to single with frequent change in string at forward slash
    By cruise.alter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2012, 06:26 AM
  7. Replies: 9
    Last Post: 03-08-2005, 05:06 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