Hello Everyone,
I've been working the past little while to create a Excel Acronym Search Engine. Everyone thus far has been a great help. I'm almost done. I'm currently combating one more issue. in the sheet labled "Acronym Search Engine" , of the attached workbook, I have created multiple text boxes. These text boxes display the search results from whats typed into the "Acronym" Text box. Now I want to deal with having multiple acronyms, I want them to display in the subsequent text boxes. I've been playing with the "SearchNext" and "SearchPrevious" but with now luck.
Does anyway have any idea how I could display multiple definitions if they did exists?
I've attached a workbook for clarification.
Thank you so much everyone
Last edited by ashleys.nl; 10-14-2011 at 11:53 AM.
how about this.
Private Sub TextBox1_Change() Dim lngIndex As Long Dim strAcronym As String Dim rngFind As Range Dim strFirstAddress As String Dim strName As String Const NTEXTBOXES = 25 ' On Error Resume Next 'Empty Text Boxes' For lngIndex = 2 To NTEXTBOXES Me.Shapes("Textbox" & lngIndex).OLEFormat.Object.Object.Text = "" Next lngIndex = 2 strAcronym = Me.Shapes("Textbox1").OLEFormat.Object.Object.Text If Len(strAcronym) > 0 Then strAcronym = strAcronym & "*" With Worksheets("Acronym Database").Range("A1").CurrentRegion.Columns(1) Set rngFind = .Find(What:=strAcronym) If Not rngFind Is Nothing Then strFirstAddress = rngFind.Address Do Me.Shapes("Textbox" & lngIndex).OLEFormat.Object.Object.Text = rngFind.Offset(0, 1).Value Me.Shapes("Textbox" & lngIndex + 1).OLEFormat.Object.Object.Text = rngFind.Offset(0, 2).Value Me.Shapes("Textbox" & lngIndex + 2).OLEFormat.Object.Object.Text = rngFind.Offset(0, 3).Value lngIndex = lngIndex + 3 If lngIndex > NTEXTBOXES Then Exit Do Set rngFind = .FindNext(rngFind) Loop While Not rngFind Is Nothing And rngFind.Address <> strFirstAddress End If End With End If End Sub
WOW! that's more than I could ask for! thank you soo much! works like a charm!
This works great, but I notice that when I use acronyms that only contain two letters I get a lot of matches because the code is searching in such a way that it doesn't have to be an exact match.
What would I change in the code to make it look for exact matches only ?
For example if I search "IM", I don't want to see the result for "FIM" or "IMS" ?
If you add the LookAt argument you can restrict it to a match with string begining with the letters. So AF would return these 3, AFC,AFD,AFE
If you only what exact matches then also alter this line by commenting out the wildcard searchSet rngFind = .Find(What:=strAcronym, Lookat:=xlWhole)
strAcronym = strAcronym '& "*"
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks