Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 54
Default Format phone numbers to look the same

Hey everyone!

I have an XL spreadsheet with tens of thousands of phone numbers, all
entered in different ways. IE

COLUMN A - PHONE NUMBER
973-555-1234
(973) 454-1291
none
(456) 555-3241
283 228 0293
home-(973) 555-1223

See - people entered data all different ways. I can't control the data
entry. But what I need to do is find a way to reformat the results so all
the numbers look like this: (###) ###-####

Can anyone help? Thanks so much!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 79
Default Format phone numbers to look the same

The following VBA (credit to the original poster) creates a User defined
Function

Alt F11 insert Module and paste the folowing code

Public Function GetNumbers(sText As String)

With CreateObject("vbscript.regexp")
.Pattern = "\D"
.Global = True
GetNumbers = .Replace(sText, "")
End With
End Function

The usage is as follows - assume that the data is in column A in B put the
following formula

=getnumbers(A1)*1 ( The *1 changes it from text to nembers so you can now
apply the custom format that you want)

edvwvw


Access Joe wrote:
Hey everyone!

I have an XL spreadsheet with tens of thousands of phone numbers, all
entered in different ways. IE

COLUMN A - PHONE NUMBER
973-555-1234
(973) 454-1291
none
(456) 555-3241
283 228 0293
home-(973) 555-1223

See - people entered data all different ways. I can't control the data
entry. But what I need to do is find a way to reformat the results so all
the numbers look like this: (###) ###-####

Can anyone help? Thanks so much!


--
Message posted via http://www.officekb.com

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 54
Default Format phone numbers to look the same

Thanks a lot. This worked!

"edvwvw via OfficeKB.com" wrote:

The following VBA (credit to the original poster) creates a User defined
Function

Alt F11 insert Module and paste the folowing code

Public Function GetNumbers(sText As String)

With CreateObject("vbscript.regexp")
.Pattern = "\D"
.Global = True
GetNumbers = .Replace(sText, "")
End With
End Function

The usage is as follows - assume that the data is in column A in B put the
following formula

=getnumbers(A1)*1 ( The *1 changes it from text to nembers so you can now
apply the custom format that you want)

edvwvw


Access Joe wrote:
Hey everyone!

I have an XL spreadsheet with tens of thousands of phone numbers, all
entered in different ways. IE

COLUMN A - PHONE NUMBER
973-555-1234
(973) 454-1291
none
(456) 555-3241
283 228 0293
home-(973) 555-1223

See - people entered data all different ways. I can't control the data
entry. But what I need to do is find a way to reformat the results so all
the numbers look like this: (###) ###-####

Can anyone help? Thanks so much!


--
Message posted via http://www.officekb.com


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Phone number format on numbers with Extensions Access Joe Excel Worksheet Functions 3 April 19th 08 01:07 AM
How do I format phone numbers in excel? CBickley Excel Discussion (Misc queries) 11 August 23rd 06 11:24 PM
Format sequence for phone numbers? LACA Excel Discussion (Misc queries) 2 June 1st 06 01:44 AM
change format for phone numbers automatically vms Excel Worksheet Functions 2 June 14th 05 11:08 PM
How can I cross reference phone numbers with existing phone numbe. John Excel Discussion (Misc queries) 1 February 11th 05 04:39 PM


All times are GMT +1. The time now is 04:19 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"