Hide characters in SSN#

gmeeks

New Member
Joined
Jun 18, 2002
Messages
21
Can anyone tell me how to enter a full SSN# but only display the last four digits. In other words enter 111-11-1111 but after you enter the number, it displays as xxx-xx-1111?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Put the following in the relevant sheet module (e.g. if your input is in Sheet 1, then put the macro in that sheet module).

The macro is set for range A1:A20. Amend to suit.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target(1), Range("A1:A20")) Is Nothing Then _
Target(1).Value = Right(Target, 4)
End Sub

HTH

Mike
 
Upvote 0
I would suggest hiding the original column with the full SS#'s and in the adjacent column put the following formula:

="xxx-xx-"&right(C1,4)

assuming the hidden column is C and data begins in row 1
 
Upvote 0
Buddie is absolutely right. I misinterpreted the question – the display is to show “xxx-xx-1111”. In addition, it makes sense putting the original SSN in one column and formatting it in another.

Amended macro:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target(1), Range("A1:A20")) Is Nothing Then _
    Target(1).Offset(0, 1).Value = "xxx-xx-" & Right(Target, 4)
End Sub
Regards,

Mike
 
Upvote 0
Or, in line with BuddieB's idea, if the full SS# is entered in C1, then in an adjacent cell enter ...

=--(RIGHT(C1,4))

Custom Number Format it as "xxx-xx-"0000

and I would hide the entry in column C and protect the worksheet, and/or hide column C all together.
 
Upvote 0

Forum statistics

Threads
1,214,527
Messages
6,120,054
Members
448,940
Latest member
mdusw

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