Formatting cells for social security #'s

kcgojnur

Board Regular
Joined
Aug 13, 2014
Messages
122
Hello -

I'm trying to create a column(F) in which the user would need to enter their 9 digit social security number without dashes. Therefore if they enter a dash, or don't enter the full 9 digits they should be prompted to do so with a pop up. I tried data validation and entered the following
Code:
=AND(LEN(F3)=9,SUM(9-LEN(SUBSTITUTE(F3, CHAR(ROW(INDIRECT("48:57"))), "")))= 9)
this doesn't seem to work b/c if I enter just the 9 digits I still get an error notification.

Any help is greatly appreciated
 
You're welcome.

There's no need to quote my posts back to me.
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I'm trying to create a column(F) in which the user would need to enter their 9 digit social security number without dashes.
Code:
          If cell.Value Like "#########" Then
            cell.Value = Format(cell.Value, "@@@-@@-@@@@")
Worked perfectly. Thanks again for all your help.
Since at the end you are going to display the SSN with dashes, why penalize the user by raising an error message if he/she includes the dashes initially? To allow the user to be able to enter the SSN with or without dashes, the snippet from shg's code shown above could be changed to this...
Code:
[table="width: 500"]
[tr]
	[td]          If cell.Value Like "#########" [B][COLOR="#FF0000"]Or cell.Value Like "###-##-####"[/COLOR][/B] Then
            cell.Value = Format([B][COLOR="#FF0000"]Replace([/COLOR][/B]cell.Value[B][COLOR="#FF0000"], "-", "")[/COLOR][/B], "@@@-@@-@@@@")[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,525
Members
448,969
Latest member
mirek8991

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