+ Reply to Thread
Results 1 to 21 of 21

Userform:Search through all ws / show results in Listbox

  1. #1
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Userform:Search through all ws / show results in Listbox

    Hello everyone,
    I have very large wordlist ( 0.5 Million Rows, 11 columns, words only in column A) and would like to search through all worksheets of it with the help of a Userform (containing one textbox for words to be searched and a listbox for the results). When I type a word in the textbox and then click on the button search, i want a list of all found results in the listbox.

    I will be thankful for each kind of help.
    Attached Files Attached Files
    Last edited by wali; 05-08-2011 at 12:18 PM.

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Userform:Search through all ws / show results in Listbox

    Hi

    Refer to the file attached. The code will search column A on sheet 1 for all cells which contain the search string entered into the search box.

    You can change the sheet that is searched by changing the line Set ws = Sheets("1").

    You say that there are potentially 1/2 million rows of data to be searched. 1) You'll notice the following lines:

    wsTemp.Range("A65000").End(xlUp)
    varLastRow = ws.Range("A65000").End(xlUp).Row

    Because your file is Excel 2003 (and limited to 65k rows), I used 65000 but you'll need to increase those if you want to use it in Excel 2007 with more than 65000 records. 2) The code uses a loop which may be slow for so many rows. If it is, let us know and we'll find an alternative.

    Hope this helps.

    Dion



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mojo249; 05-06-2011 at 07:14 PM.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali
    Do you have a defined list of search terms or is it truly free style?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    Hi Mojo249,
    thank you very much for your solution. It works great with 0.5 Million words and fast.
    The thing is that i work in a very large firm where they have only office 2003 and we are not allowed to install own software. Thats the reason that i splitted the large wordlist into many ws so that i can use it with excel 2003.
    I will be very gratefull if you could add one more modification in the code: I need to copy and paste sometimes one of the results and its not working for me at the moment with shorcutkeys of copy and paste. Can you maybe add another button "copy" so that i can copy the selected result and then paste it where I want?

    thank you very much

    Hi jaslake,
    thanks for your interest and for reading my problem. Sorry, but i couldnt understand you question.
    Last edited by wali; 05-07-2011 at 12:25 AM.

  5. #5
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    Hi,
    i got two more problem with it.

    1) I added one more column and it shows me "Error typ 13" at following ling:

    Please Login or Register  to view this content.
    2) it does not search through all ws
    Last edited by wali; 05-07-2011 at 07:28 AM.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali
    What I am asking is if you have a list of words that you'll frequently be searching for.

  7. #7
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    hi jaslake,
    yes I will be using the same wordlist hundret times a day :-)

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali
    Give me a sampling of the word list you'll be using...as many as you like...but at least 10 to 15. Please include the word list on a worksheet in a new copy of your Excel file. The new Excel file should also include this
    I added one more column and it shows me "Error typ 13"

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali
    I attempted to respond to your private message but was blocked. The purpose of the Word List would be to enhance the entry of words that you typically use in the Search Textbox. If you use the same words over and over, the Search Textbox could be made to AutoFill as you type. A Dictionary is not what I had in mind...only a list of frequently searched for words.

    Attached is a workbook with revised code that accommodates this
    it does not search through all ws
    If this is a continuing issue
    I added one more column and it shows me "Error typ 13"
    then I'll need to see your new file with the additional column.

    Regarding this
    I need to copy and paste sometimes one of the results and its not working for me at the moment with shorcutkeys of copy and paste. Can you maybe add another button "copy" so that i can copy the selected result and then paste it where I want?
    As you discovered, one cannot copy/paste from a ListBox on a UserForm. However, with code, you CAN place one or multiple items that you select into another location in the workbook. If you describe what you wish to do, I believe the code can be added to allow you to select an item from the results ListBox and place it "where you want".
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    Hi,

    first of all thank you very much for spending your time to solve my problem.

    1) The file you have attached contains no code.
    2)
    If you describe what you wish to do, I believe the code can be added to allow you to select an item from the results ListBox and place it "where you want".
    I would like to add another ws "de-ps" to the file and would like to paste the higlighted results into the last row of the ws "de-ps". I would need another button "copy" in the userform for that purpose.

    3) I didnt post the original large list here cus of copy right matters
    Attached Files Attached Files

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali

    Try this attachment...sorry 'bout that...don't know what happened.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    cool!! now it shows results from all columns. I will check it with real wordlist and come with feedback

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali

    Private messaging is a reasonable tool for confidential information...however, if it's limited to one way conversation, it serves no purpose. Either you've blocked private messaging or your environment doesn't allow it.
    Either turn private messaging on on your end or don't send them to me. I've tried twice to respond to your private messages and have been blocked. Frankly, it doesn't make me happy.

    The link you provided links to a Dictionary
    http://www.qamosona.com//downloads/dict2.rar

    I've not introduced this dictionary to the code so I'd suggest it's not a source of your issue. Post a file that demonstrates your issue and perhaps I can help you resolve it.

    In the meantime, the attached appears to resolve this
    I would like to add another ws "de-ps" to the file and would like to paste the higlighted results into the last row of the ws "de-ps".
    Let me know of issues.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    Hi,
    i am very sorry for the thing with private message. Each time I tried to send you a private message, i was told that its not possible to do so cus "you are not in my contacts or blocked" ??..?. And then i found a check box below "send the message any how.." and as i activated it, i was able to send you the message. I looked into my acount settings and couldnt find where to modify it in a way so that each member can send me private messages. Any way sorry for that! I dont know yet how to change the settings.

    Now to the code:
    1) the file i have uploaded contains the excel file with original wordlist. I have named it "dict" but its an excel file (compressed as rar) the same as you have worked with. The only difference is that the one i have sent you the link of contains 0.5 million words (each worksheet contains smaller amount of rows than 56000). And i think the source of error is just the larger number of rows.
    The code you have sent works perfectly with small list. But as soon as i try it with large list it shows me erron on following code line:

    If InStr(LCase(ws.Cells(varRow, 1).Value), varSearchString) <> 0 Then

    2) Can the code be modified in such a way that it doesnt delet/replace the content of ws "de-ps" after copy button is pressed? It will be great if it searches for the last row and copies the selected result under the last row of "de-ps".
    Last edited by wali; 05-07-2011 at 05:29 PM.

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali

    Regarding this
    Can the code be modified in such a way that it doesn't delete/replace the content of ws "de-ps" after copy button is pressed?
    In this code
    Please Login or Register  to view this content.
    Either delete or comment out this line of code
    Please Login or Register  to view this content.
    Regarding this
    the file i have uploaded contains the excel file with original wordlist. I have named it "dict" but its an excel file (compressed as rar) the same as you have worked with.
    I don't currently have a utility to uncompress .rar files but I know they're freely available. I'll look into that but I use .zip files. If you could use .zip, that may be helpful.

    I'd assume the .rar file is much of our communication issue. However, IF you have a file that has a half million entries, how many do you use on a regular basis...10, 100, 1000, 10,000??? You can add to the list as you please.

  16. #16
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    Hi,
    thank you very much for the modifications. Unfortunately it again works only with small amount of rows. As soon as I try to use it with the original wordlist (0.5 Million Words) it shows me erro in line :

    If InStr(LCase(ws.Cells(varRow, 1).Value), varSearchString) <> 0 Then

    I use always the same list which has about 0.5 rows, which I am now uploading. I am sending you here the link for download.

    "link was removed"

    Please, let me know after you have downloaded it, so that i can delete the link again (cus of copy right matters)

    regards

    Regards
    Last edited by wali; 05-08-2011 at 12:09 PM.

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali
    I've downloaded your zip file. The procedure halts when it gets to row 8270 of Sheet 1. The data in A8270 is bad data (#NAME?). If you figure out what's causing the bad data, the procedure should run fine.

    The procedure probably could be modified to skip these invalid items. Let me know how you wish to proceed.

    PS: after seeing your file, I see I totally misunderstood what you were saying. I apologize.
    Last edited by jaslake; 05-08-2011 at 10:12 AM.

  18. #18
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali

    Should you choose to go this route
    The procedure probably could be modified to skip these invalid items
    insert two lines of code as follows
    Please Login or Register  to view this content.
    Let me know how you make out.

  19. #19
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    Re: Userform:Search through all ws / show results in Listbox

    WOOOOOOW it works! Thanks a million time John! It really was bad data in there. But i didnt remove it and added to lines more code you had suggested. It works great. Thaaaaaaaaaanks! you saved my life!

  20. #20
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Userform:Search through all ws / show results in Listbox

    Hi wali

    Glad I could help.

  21. #21
    Registered User
    Join Date
    01-18-2015
    Location
    chile
    MS-Off Ver
    2010
    Posts
    12

    Re: Userform:Search through all ws / show results in Listbox

    Quote Originally Posted by wali View Post
    cool!! now it shows results from all columns. I will check it with real wordlist and come with feedback
    Hello, i'm from Chile, and i have been viewing this conversation. Do you have perchance the file that contains for search all columns?

    thanks.

    i hope your answer

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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