NINO Data Validation

Im Sarah

New Member
Joined
May 17, 2017
Messages
2
Hi All

I'd really appreciate some help with formatting cells with UK National Insurance Numbers. These consist of letters and numbers with spaces in between such as seen below where T represents any letter and 0 represents any 0 - 9 number

TT 00 00 00 T

The way I was doing it was just to emit the spaces and validate the cell to 9 characters however I am now told I MUST format the NINO with the spaces in. I've done some research on these message boards but haven't found an answer as yet. I'm still at novice level so have no clue about code and macros unfortunately.

If I didn't need the spaces as shown above I think this would have worked but I don't know how to tell it to put the spaces in.

=AND(LEN(A1)=9,ISERROR(MID(A1,1,1)*1),ISERROR(MID(A1,2,1)*1),ISNUMBER(MID(A1,3,6)*1),ISERROR(MID(A1,9,1)*1))

Please help!

Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
TT 00 00 00 Tok
TT 00 00 0 0Terror5
T 00 00 00 TTerror2
TT000000Terror1
TT000000 Terror2
TT 00 000 0 Terror4
TT 000 0 00 Terror3
TT 00 00 00 Tok
formula in D1
=IF(LEN(A1)<>13,"error1",IF(MID(A1,3,1)<>" ","error2",IF(MID(A1,6,1)<>" ","error3",IF(MID(A1,9,1)<>" ","error4",IF(MID(A1,12,1)<>" ","error5",IF(ISERROR(MID(A1,4,2)*1*MID(A1,7,2)*1*MID(A1,10,2)*1),"error6","ok"))))))
still need to check letters are letters and numbers are numbersA65
aand ensure spaces are where they should beZ90
12345678910111213OUTCOMEa97mytable
TT 00 00 00 Tyyyyyyyyyyyyyokrow 21z122
T0 00 00 0 0Tyoopsyyyyyyyyoopsoopsyerror-444oops
T 00 00 00 TTyoopsoopsyoopsoopsyoopsoopsyoopsoopsyerror1oops
TT 00 00 00TTyyyyyyyyyyyoopsyerror65y
TT000000 Tyyoopsyyoopsyyyoopsoopsyyerror91oops
TT 00 000 0 Tyyyyyyyyoopsoopsyyyerror97y
TT 000 0 00 Tyyyyyoopsoopsyyyyyyerror123oops
TT 00 00 00 Tyyyyyyyyyyyyyok444oops
B21
=VLOOKUP(CODE(MID($A21,B$20,1)),mytable,2)
copied to C col, and N columnmytable2
-444oops
48y
D2158oops
=IF(CODE(MID($A21,D$20,1))<>32,"oops","y")444oops
copied to G col, J col, M col
E21
=VLOOKUP(CODE(MID($A21,E$20,1)),mytable2,2)
copied to F,H,I,K,L

<colgroup><col><col><col><col><col><col><col><col><col><col><col span="4"><col><col span="13"></colgroup><tbody>
</tbody>
 
Upvote 0
Many thanks for your reply, I really am quite basic on excel (although I am trying my best) and don't know how to implement what you have written. I tried the formula you had written below d1 and put it as a custom data validation but it didn't work. :confused::confused::confused:

Basically I have a thousand or so National Insurance numbers that have been recorded as TT000000T and I need to format the cells to put the gap in so they all read TT 00 00 00 T

Please help :eek:
 
Upvote 0
so the NEW question is different lol

use find and replace

find TT0 replace with TT 0

gives TT 000000T

find 000000 replace with 00 00 00 (and a space after the last 0 that You have to accept is there)

JOB DONE

IT WILL IGNORE ALL OTHER VARIANTS LIKE TT 00 00 00 T OR TT 00 0000 T
 
Upvote 0
forget my last post

assuming the NI numbers are in column A

for j=1 to 10000
if len(cells(j,1))=9 then cells(j,1)=left(cells(j,1),2)&" "&mid(cells(j,1),3,2)&" "&mid(cells(j,1),5,2)&mid(cells(j,1),3,2)&mid(cells(j,1),7,2)&right(cells(j,1),1)
next j
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,793
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top