View Single Post
 
Old 07-31-2020, 10:39 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You can't merge part of a field, but if you were to use https://www.gmayor.com/email_merge_addin.html to merge to separate documents, you could use the following macro with it to get the last four digits of any 16 digit number

Code:
Sub LastFour(oDoc As Document)
Dim oNum As Range
    Set oNum = ActiveDocument.Range
    With oNum.Find
        Do While .Execute(findText:="[0-9]{16}", MatchWildcards:=True)
            oNum.Text = Right(oNum, 4)
            oNum.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oNum = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote