Format National Insurance Number

M

M-Hop

I am using an excel record for mailmerge and would like to format a national
insurance record. The text field is for example AA112233B, and I would like
to merge the field divided into separated segments eg. AA 11 22 33 B.
Dates and numerical data are fine, but I'm not sure exactly what is needed
for alpha-numeric?
 
G

Graham Mayor

As far as I am aware, there is no simple way to do this.

The options are:
1. Format it correctly in the Excel data file
or.
2. Derive three additional fields from the NI field using LEFT RIGHT and MID
functions in Excel to separate the three parts of the number i.e. 2 letters
6 numbers 1 letter and merge those fields - wherein you can format the
number field in Word with a switch
http://www.gmayor.com/formatting_word_fields.htm
or
3. Merge to a new document and run a macro to format the number:

Sub FormatNI()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([A-Z]{2})([0-9]{2})([0-9]{2})([0-9]{2})([A-Z])"
.Replacement.Text = "\1 \2 \3 \4 \5"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top