#1   Report Post  
Posted to microsoft.public.excel.programming
jb jb is offline
external usenet poster
 
Posts: 6
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
jb jb is offline
external usenet poster
 
Posts: 6
Default 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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"