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?
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
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
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.