ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Replace first part of SS# with x's (XXXX-XX-9999) (https://www.excelbanter.com/excel-programming/297347-replace-first-part-ss-xs-xxxx-xx-9999-a.html)

Jenpher

Replace first part of SS# with x's (XXXX-XX-9999)
 
I am trying to write a code that will take the full social securit
number 9999-99-9999 and turn it into the following: XXXX-XX-9999, th
first numbers can be deleted, with only the last four remaining. I kno
this is really simple for you pros out there, but I cannot do it!
Please help me!

--
Message posted from http://www.ExcelForum.com


Jake Marx[_3_]

Replace first part of SS# with x's (XXXX-XX-9999)
 
Hi Jenpher ,

I am trying to write a code that will take the full social security
number 9999-99-9999 and turn it into the following: XXXX-XX-9999, the
first numbers can be deleted, with only the last four remaining. I
know this is really simple for you pros out there, but I cannot do
it!! Please help me!!


I'm assuming you mean xxx-xx-9999, as the standard SSN has 3 digits, a
hyphen, 2 digits, a hypen, then 4 digits.

Here's a function that will do that for you:

Public Function gsMaskSSN(rsOrigSSN As String) As String
If rsOrigSSN Like "###-##-####" Then
gsMaskSSN = "xxx-xx-" & Right$(rsOrigSSN, 4)
Else
Err.Raise 10001, "gsMaskSSN", "Invalid SSN"
End If
End Function

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Jenpher[_2_]

Replace first part of SS# with x's (XXXX-XX-9999)
 
I've looked a lot of places but I don't know where to paste it and the
apply the format afterwards. Any help is very, very appreciated. Than
you!

--
Message posted from http://www.ExcelForum.com


Jenpher[_3_]

Replace first part of SS# with x's (XXXX-XX-9999)
 
no messag

--
Message posted from http://www.ExcelForum.com


Jake Marx[_3_]

Replace first part of SS# with x's (XXXX-XX-9999)
 
Hi Jenpher ,

I've looked a lot of places but I don't know where to paste it and
then apply the format afterwards. Any help is very, very appreciated.
Thank you!!


Most code goes in a Standard Module. To create one, open the VBE (Alt+F11
from Excel), then select Insert | Module. You can paste the code in there.

The code I gave you was set up as a function. This means that you pass in
one or more values, and the function returns a value to you. The code used
to pass in the SSN will vary depending on what it is you're trying to
accomplish. Where are the SSNs stored, and how do you want them outputted?
Or do you just want to take all SSNs in a worksheet and mask them using this
function? Do you need to retain the original values somewhere?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Gord Dibben

Replace first part of SS# with x's (XXXX-XX-9999)
 
Jenpher

If "the first numbers can be deleted"......

In an adjacent column enter

=RIGHT(A1,4) and drag/copy down.

Assumes Column A has your SSN's

When done, you can copy the column and paste specialvaluesOKEsc

Delete the original column.

Gord Dibben Excel MVP



On Wed, 5 May 2004 13:06:12 -0500, Jenpher
wrote:

I am trying to write a code that will take the full social security
number 9999-99-9999 and turn it into the following: XXXX-XX-9999, the
first numbers can be deleted, with only the last four remaining. I know
this is really simple for you pros out there, but I cannot do it!!
Please help me!!


---
Message posted from http://www.ExcelForum.com/



Jon Peltier[_7_]

Replace first part of SS# with x's (XXXX-XX-9999)
 
.... or

="XXX-XX-"&RIGHT(A1,4)

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Gord Dibben wrote:

Jenpher

If "the first numbers can be deleted"......

In an adjacent column enter

=RIGHT(A1,4) and drag/copy down.

Assumes Column A has your SSN's

When done, you can copy the column and paste specialvaluesOKEsc

Delete the original column.

Gord Dibben Excel MVP



On Wed, 5 May 2004 13:06:12 -0500, Jenpher
wrote:


I am trying to write a code that will take the full social security
number 9999-99-9999 and turn it into the following: XXXX-XX-9999, the
first numbers can be deleted, with only the last four remaining. I know
this is really simple for you pros out there, but I cannot do it!!
Please help me!!


---
Message posted from http://www.ExcelForum.com/






All times are GMT +1. The time now is 10:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com