ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FormatSSN (https://www.excelbanter.com/excel-programming/283081-formatssn.html)

jb

FormatSSN
 
Does anyone have the VBA code that will take a SSN and put the - in it?
I usually use the format cell, but the last couple of spreadsheets I
have worked on will not recognize the command for some reason.

Thanks


Chip Pearson[_2_]

FormatSSN
 
Try something like

SSN = Format(123456789, "000-00-0000")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"jb" wrote in message
...
Does anyone have the VBA code that will take a SSN and put the - in it?
I usually use the format cell, but the last couple of spreadsheets I
have worked on will not recognize the command for some reason.

Thanks




Tom Ogilvy

FormatSSN
 
Suspect your SSN's are stored as text rather than numbers. You can test by
selecting the column and do

Edit=Goto=Special and select Constants and Text. If it selects all your
SSN's then that is the problem.

You need to format the cells as General, then do

Data=Text to Columns, select delimited and select tab as the delimiter.
This will cause excel to reevaluate your SSN's and change them to numbers.
Then your format should work.

--
Regards,
Tom Ogilvy


"jb" wrote in message
...
Does anyone have the VBA code that will take a SSN and put the - in it?
I usually use the format cell, but the last couple of spreadsheets I
have worked on will not recognize the command for some reason.

Thanks




jb

FormatSSN
 
Tom:

That was the problem.

Thanks

Tom Ogilvy wrote:
Suspect your SSN's are stored as text rather than numbers. You can test by
selecting the column and do

Edit=Goto=Special and select Constants and Text. If it selects all your
SSN's then that is the problem.

You need to format the cells as General, then do

Data=Text to Columns, select delimited and select tab as the delimiter.
This will cause excel to reevaluate your SSN's and change them to numbers.
Then your format should work.




All times are GMT +1. The time now is 01:50 AM.

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