Hello,
You can look the below link for your answer.
http://www.experts-exchang
Main Topics
Browse All TopicsI have an excel file composed of 3 sheets (could be combined into one) that is being used for donated inventory tracking. It details the names of the donors, and then in other cells goes on to include info about the title of the item donated, the date it was donated, and so on.
Is it possible to make a VB form that could search the excel file by first and/or last name and display returned matches (partial or whole), along with the corresponding data from the other cells?
Example: Search for "willis" returns
Name: Willis, Bruce
Title: Bruno album
Date: 10/22/90
Also, if there's an easier way to accomplish this, with or without VB, please speak up. I'm a total newb at VB, but it's the only tool I have at my disposal that I have any experience with.
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hello,
You can look the below link for your answer.
http://www.experts-exchang
do you mean a vb6 form or vba user-form (from within excel?
beacuse that would change the actual access to the excel fiel (if you're inside the excel file, then no references and Open command are needed)
so for now i'll skip the vb6 and assume vba from within the open excel file
take a look at the user form inthe vba section of the attached file
you can see there that any sheetcan be referenced and searched, and i use cells(row,col) instead of the Range(..) method cause it's easier to program with
hope that's what you asked for
ErezMor -
Thanks very much for the provided sample; it was very helpful. I am looking for a solution that would work from outside Excel, though. The issue is that we want people to be able to search the spreadsheet if they already have an idea of the name they're looking for, but not necessarily have access to the spreadsheet itself. Also, would it be possible return results from partial search matches? So, in the example you provided, searching for "maya" or "may" would both return the results for maya? That also makes me wonder, how could multiple results be handled? If there's both a "maya" and a may" in the spreadsheet, and the search for "may" returns both results, what would be the best way to handle the display of the results?
hello again
so moving the code to an independant vb is not hard, you need to go to references in your vb application and find "Microsoft excel ..."
add the necessary controls as it was in the user form, then use the code attached here in the search button click
look at the difference in the code to allow for partial matches (use of InStr function instead of equation), and the ability to keep searching (by hitting the "Search" button again, beacuse i variable turned to static it keeps looking down the spreadsheet as long as the value search has not been changed)
this is just sticking with the original structure, you might consider returning a whole table of results and not the 1 by 1 solution here.
or even connection by ADO or DAO and returning a recordset (which you can display as a datagrid)
Thanks so much for all the help, but I can't seem to get your provided code to work, and I don't have the knowledge to troubleshoot it When I start debugging the form pops up fine, but after clicking the "search" button, I get an "InvalidCastException was unhandled" error, with the following details:
Overload resolution failed because no Public '<>' can be called with these arguments: 'Public Shared Operator <>(a As String, b As String) As Boolean': Argument matching parameter 'a' cannot convert from '__ComObject' to 'String'.
Am I missing something?
Okay, fixed the above error. I made some minor changes to the code to accommodate the way the source spreadsheet is set up (the vital info I want returned upon a successful search is found in the 2nd, 3rd, 4th, and 10th columns only, with the names being located in the 2nd column). No crashes, no errors. The app just can't find anything I search for. Always returns "no results found." Any ideas? I'm including my code:
ok
this code run from a button click event on a windows form that has a datagridview for results (3 columns Name, Title, Date) named "dgvResults", a text box for the name searched called "txtName" and the above button, and it works on the excel file gave you so no excuses this time.
in ths implementation you do not need to add references to excel cause it's late bound (declared inside the code) but you will need excel on the target machine
to ignore case, change the istr function to
InStr(1, .Cells(i, 1).Value, txtName.Text, CompareMethod.Text)
about your excel file, i cant really help without seeing it, remember that the code i gave you determines the end of the database by finding a blank cell in row 1. are there blank cells inside your table?
Business Accounts
Answer for Membership
by: Rahu_ketu_patalPosted on 2009-07-02 at 23:51:12ID: 24770466
yes you can use that using ODBC connection using VB.Net and C# both om/UploadF ile/mgold/ Query2Exce l120320050 11029AM/Qu ery2Excel. aspx
http://www.c-sharpcorner.c