+ Reply to Thread
Results 1 to 3 of 3

Thread: Excel macro for UK national insurance number

  1. #1
    Registered User
    Join Date
    02-02-2011
    Location
    newcastle
    MS-Off Ver
    Excel 2007
    Posts
    2

    Excel macro for UK national insurance number

    Hi Guys, i have an excel spreadsheet and i've written a macro to try to put dashes (hyphen) in between the letters and numbers. I believe i'm nearly there but if you look at the attachment i can't seem to get a dash in between the last two characters. For example, in the first number i need a dash in between the 8 and the A. I've tried adding extra mids and altering the number in the Right value but to no avail. Please help, this is driving me nuts!!
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,235

    Re: Excel macro for UK national insurance number

    Formula:
    =LEFT(A29,2)&"-"&MID(A29,3,2)&"-"&MID(A29,5,2)&"-"&MID(A29,7,2)&"-"&RIGHT(A29,1)

        ActiveCell.FormulaR1C1 = _
            "=LEFT(RC[-1],2)&""-""&MID(RC[-1],3,2)&""-""&MID(RC[-1],5,2)&""-""&MID(RC[-1],7,2)&""-""&RIGHT(RC[-1],1)"

    Regards

  3. #3
    Registered User
    Join Date
    02-02-2011
    Location
    newcastle
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Excel macro for UK national insurance number

    cheers TMShucks, this worked a treat. extremely grateful, many thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0