Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to show only the last 4 digits of social security number (ssn) in Excel?

For keeping the social security number privacy, many Excel users tend to show only the last 4 digits of the ssn in Excel. This article will show you methods to hide all numbers of ssn number except the last 4 digits in Excel.

Show only the last 4 digits of ssn with formula

Show only the last 4 digits of ssn with VBA code

Delete all digits of ssn except the last 4 digits with Kutools for Excel


Easily delete all digits of ssn except the last 4 digits in Excel:

With the Remove by Position utility of Kutools for Excel, you can delete all digits of ssn except the last 4 digits as below screenshot shown.

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!

Enable you to do smarter, faster and better

Kutools - the best office productivity tool brings 300 advanced features to Excel. Details... Download...

Office Tab - brings tabbed interface to Excel and Word, make your work much easier. Details...Download...


Show only the last 4 digits of ssn with formula


The following formula can help you show only the last 4 digits of ssn in Excel. Please do as follows.

1. Select a blank cell, enter formula =RIGHT(A2,4) into the Formula Bar, and then press the Enter key. See screenshot:

Note: In the formula, A2 is the cell contains the social security number.

2. Keep selecting the first result cell, drag the Fill Handle down to get all results as below screenshot showed.


Show only the last 4 digits of ssn with VBA code

The following VBA code can help you showing only the last 4 digits automatically when entering the social security number. Please do as follows.

1. In the worksheet you want to only show the last 4 digits of the social security number, right-click the sheet tab and click View Code from the right-clicking menu. See screenshot:

2. In the Microsoft Visual Basic for Applications window, copy below VBA code into the Code window.

VBA code: Show only last 4 digits of the social security number in Excel

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim I As Long
    Dim xVal As String
    On Error Resume Next
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    For I = 1 To Target.Count
        If Len(Target(I).Text) >= 4 Then
            Target(I).Value = Right(Target(I).Value, 4)
        End If
    Next
    Application.EnableEvents = True
End Sub

Note: In the code, A:A is the column you will enter social security number into. Please change it as you need.

3. Press the Alt + Q keys to exit the Microsoft Visual Basic for Applications window.

From now on, when entering social security number into cells in column A, all digits will be hidden automatically except for the last 4 numbers.


Delete all digits of ssn except the last 4 digits with Kutools for Excel

You can remove all numbers from the social security number except for the last 4 digits with the Remove by Position utility of Kutools for Excel. Please do as follows.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

1. Select all cells containing social security numbers, then click Kutools > Text > Remove by Position. See screenshot:

2. In the Remove by Position dialog box, select the From left option in the Position section, specify how numbers you will remove from left in the Numbers box (here I enter number 7), and then click the OK button. See screenshot:

Then all numbers are removed from the selected cells except for the last 4 digits.

Tip.If you want to have a free trial of this utility, please go to download the software freely first, and then go to apply the operation according above steps.



Excel Productivity Tools

Kutools for Excel - The Best Office Productivity Tool

  • Brings 300 powerful advanced features to Excel, enable you to do smarter, faster and better.
  • No longer need memorizing formulas and VBA codes, give your brain a rest from now on.
  • Become an Excel expert in 3 minutes, Complicated and repeated operations can be done in seconds, 
  • Reduce thousands of keyboard & mouse operations every day, say goodbye to occupational diseases now.
  • 110,000 highly effective people and 300+ world-renowned companies' choice.
  • 60-day full features free trial. 60-day money back guarantees. 2 years of free upgrade and support.

Office Tab - brings tabbed interface to Office, make your work much easier.

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.