Consulting

Results 1 to 6 of 6

Thread: How to find exact match in a word macro

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    How to find exact match in a word macro

    I am using the below macro to search a document to find a ticker that I type into an input box from an excel document and use it to populate a report based on the horizontal data that corresponds to the mail merge fields in word. I am using the below macro - which for the most part works perfectly. However, if I type in a ticker with less than 4 characters it produces the first instance in the list that includes the letters in the input box. For example, if I type in AM it returns AKAM which appears first in the list. I want to be able to type in AM and get AM. Help!

    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
    Last edited by kpangman; 02-25-2020 at 02:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •