Format SSN - Updated formula


February 20, 2008 – 6:56 pm by JP

Here is an update to the code I have posted on the site at

Format SSN

I realized that the last part of the formula doesn’t check for dashes. Here is the updated formula:

=IF(AND(LEN(A4)>6, LEN(A4)9, NOT(ISERROR(FIND(”-”,A4)))),A4,LEFT(A4,3)&”-”&MID(A4,4,2)&”-”&RIGHT(A4,4)))

Notice the addition of NOT(ISERROR(FIND(”-”,A4))) in the second IF formula.

If the formula already has dashes in it, it will simply return the value in A4.

Enjoy,
JP


If you enjoyed this page, share it!
    StumbleUpon Technorati Digg Google del.icio.us MisterWong TwitThis

Print This Post Print This Post  |  Email This Post Email This Post  |  rss Subscribe to Posts Feed  |  rss Subscribe to Comments

Filed Under: Excel, Formulas
Tags: , , , ,

Post a Comment


Certain comments (including first-time comments) are subject to moderation and will not appear immediately. You can use HTML tags in your comment. If you include a greater-than or less-than sign or anything else that could be interpreted as HTML, you need to escape those characters. To post VBA code in your comment, use [VBA] tags, like this: [VBA]Code goes here[/VBA].





Subscribe without commenting

Keep Reading:

Browse Posts:


« Import data to Access from Excel || HTML Object Libraries »