Calling all VBA wizards - Please help if you can!!!
I am using the below macro in word to pull data into a template from excel using mail merge. Essentially, I have a database that outlines data by ticker (which are identified by anywhere from 1 - 5 letter symbols (example Google = GOOGL and Sprint = S)). I want my macro, when run, to allow me to type in a certain ticker into an input box and the macro (along with the mail merge) will search the database for that ticker and then will populate the mail merge document with applicable data. Everything works really well for those tickers with 3 - 5 letters. The problem I am running into is when I type in tickers that have 1 or 2 letters. What happens is instead of searching the document for the exact match of the ticker that I input, it finds the first instance of that string of letters. For example, if the ticker was AM the macro would pull in data for AKAM which comes before AM alphabetically and is therefore the first instance of AM in the document. My question is: Is there a way to write a macro just like I have below (since it mostly works) that would only populate data relevant to the EXACT ticker I type in rather than just searching the document for the first instance of the letters I type in. My current macro is below:
Sub Macro()
Dim numRecord As Integer
Dim Ticker As String
Ticker = InputBox("Enter the Ticker:")
Set dsMain = ActiveDocument.MailMerge.DataSource
If dsMain.FindRecord(FindText:=Ticker, Field:="Ticker") = True Then
numRecord = dsMain.ActiveRecord
End If
End Sub
I have posted to this forum before with this same question and over 400 people viewed the thread but no one responded. If this isnt possible to do, it would be great to know that too. I would really like any insight even if it doesnt give me a perfect solution.
Thanks so much for the help ahead of time!!!!!