+ Reply to Thread
Results 1 to 14 of 14

Create List of results from a input search, select desired result, paste into worksheet

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Create List of results from a input search, select desired result, paste into worksheet

    Hi guys, great forum!
    I've been using excel for many years but relatively new to VBA.
    I have attached a simplified version of my invoicing book which needs some fine tuning.

    a) What it does at the moment:
    - Sheet 1 (Invoice) - user either enters the part numbers directly into cells C7:C14 to populate corresponding cells D7 to E14, or clicks the search command button on the left which brings up an Input to enter keyword search. The keyword searches via multiple partial keywords separated by spaces (many thanks to whomever created the script!).
    - Sheet 2 (ProductList) - obviously contains the data we are searching through.

    b) What I would like:
    - At the moment the VB script highlights the cells anywhere in the workbook that contain search results (it pages through each subsequent worksheet)
    - a blank "" search also produces some result (which ain't good)
    - I would like the search result to be populate a popup list (which updates real time if possible as you add keywords into the Input Box)
    - Then, I would like to be able to select one of the results amongst the list of results, and have this selection transpose to the appropriate line in Invoice Sheet (Part No, Description, Price).
    - I don't need the cells to be highlighted (I've left this in the VBA for now so you can easily view the script that produces results)

    Any help would be greatly appreciated, thanks in advance for your time and thoughts.
    Eddie
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Create List of results from a input search, select desired result, paste into workshee

    So far I've only been able to add a form/listbox and have it pop up after my query ...
    I have had no luck getting it to populate. confused about code required, and where to place it (forms or module).
    attached is my progress (if that's what you'd call it!), any ideas out there? InvoiceProducts2.xlsm

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Create List of results from a input search, select desired result, paste into workshee

    Here is my solution , hope this helps.
    Attached Files Attached Files
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Create List of results from a input search, select desired result, paste into workshee

    Hi Xlbiznes,
    Thank you for your help. This is a huge step forward and quite functional. I also see how wrong my approach was and now learning from your code and where you've placed it compared to my initial effort.

    Can I request some changes if you are able to make them?
    I noticed that the part numbers have to start with '0' - although on my example sheet, the data does have part numbers that start with 0, this is just sample data that I pasted from the net just to create something. In practice, part numbers might start with any number or letter (e.g. 03-443232, or PTS9903, SS-4324-44 etc...) – Are you able to amend the code to accommodate this ? I see how in your code you've include '0' to ensure column 'A' is searched first. If not possible, perhaps two text boxes used to search (one for part number search, one for description)?

    Regarding the search functionality, the original search was able to search within a cell for partial keywords, in any order and quantity of keyword, and it excluded results with the addition of keywords (e.g. entering a search "sel lab rol" - would still bring up a product description that contains: "self adhesive roll labels", even though the order is wrong).
    The current search input has to sequentially match the target cell (e.g. entering the above search would not yield a result, but you would have to search "sel*rol*lab" in sequence, with * between keywords, to get the same result).
    I really appreciate your help thus far, it's huge!
    Many thanks,
    Eddie

  5. #5
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Create List of results from a input search, select desired result, paste into workshee

    With regard to wildcard search , can the user enter the search string like sel*rol*lab and it would fetch the needed result.

  6. #6
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Create List of results from a input search, select desired result, paste into workshee

    As far as the search is concerned we can make the search look into column a and b for any input so this will take care of any search entry done by the user.

  7. #7
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Create List of results from a input search, select desired result, paste into workshee

    Hi, yes, ok if it searches both columns. Regarding the order of the keywords, it would be ideal if it could search in any order, sel rol lab, rol lab sel, etc... and still call the same result, like on the first workbook. This is because the product sheet will potentially hold many thousands of entries. Unfortunately products do not follow a specific protocol for the description (e.g. product1: "table, dinner, timber, stained, 6 seater", product2: "dinner table, timber, 6 seater, black" - need to find both using keyword "dinner, table". What do you think? Are you able to incorporate the search code from the first wbk? Thanks again in advance!!

  8. #8
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Create List of results from a input search, select desired result, paste into workshee

    this is the updated file, search enabled on both columns A : B .

    As far as string search is concerned, use * before the string to in your real time data and see if it brings up the desired result.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Create List of results from a input search, select desired result, paste into workshee

    Hi Xlbiznes,
    Thank you very much, I greatly appreciate your help.
    The A:B works well. The * before the search doesn't create the search but to be honest, I think I am asking to much to have both multiple keywords search in any sequence producing real time drop-down list. Nonetheless, what you have provided is great and it will do fine
    Oh, one more thing, if you get a chance, if we were to expand to include searching in column C, would this be:

    Set Rng = wks.Columns("A:C").Find(What:=Me.TextBox1.Value, After:=wks.Range("A" & wks.Rows.Count).End(xlUp))

    or require an additional loop?

    P.S. Hope you have a great 2014.
    Cheers,
    Eddie

  10. #10
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Create List of results from a input search, select desired result, paste into workshee

    the code you have posted is perfect , if you want to search from column a:c .

  11. #11
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Create List of results from a input search, select desired result, paste into workshee

    Hi again,
    I changed the code ("A:C") as above, also included a category in product list (column B of product list) -- I have found that when you search now, if the name of the category is the same text in the description, then your search will not include other items in the category, it stops at the first row found that matches.

    I have attached the modified sheet (only changed B to C, and included category) Updated InvoiceProducts - Xlbiznes-3.xlsm.
    e.g. try to search "GLE", this will bring up only one line, and not the other items that include GLE in either description or category.

    Cheers, Eddie

  12. #12
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Create List of results from a input search, select desired result, paste into workshee

    done, check this updated file.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Create List of results from a input search, select desired result, paste into workshee

    That's great!!! works very well. Thank you again!

  14. #14
    Registered User
    Join Date
    01-20-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Create List of results from a input search, select desired result, paste into workshee

    Nice, I was looking for the change to your code: And ctr > 1.

+ 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] Using a button to select Non-Zero values from a list and paste the results to a textbox
    By Thy_Raven13 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-10-2013, 07:44 AM
  2. Replies: 3
    Last Post: 09-12-2012, 04:58 AM
  3. Excel Macro help to copy/paste results using input values from a list box
    By kamila7 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-13-2012, 04:46 PM
  4. My macro does not paste results in the desired row
    By GrandKahuna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-07-2011, 05:27 AM
  5. Replies: 1
    Last Post: 05-25-2006, 02:30 PM

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