I am desperate for some help on this one. The problem is now accepting numbers starting with zero but it does involve formatting/ masks.
I have a sheet with many mobile/ cell phone numbers:
07771123456 for example
But I need to change this format to drop the "0" and add the country code "44", so need to automate this somehow with a mask/macro.
07771123456 needs to change to 447771123456 and there is thousand of these so I cant face any more hours of doing it manually, there is a way isnt there? please for my sanity
I use office 2007.
Last edited by pdiminski; 02-16-2010 at 02:01 PM.
if they are all the same length use in another column
=44&RIGHT(A1,10)
drag down then copy column paste back special values
if different lengths then
=44&MID(A1,2,20)
should cover it
Last edited by martindwilson; 02-10-2010 at 12:00 PM.
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
you could use substitute -->=SUBSTITUTE(A1,0,44) <-- A1 is the old 07771123456 would change it to 44777123456. Is that something you could work with?
Please acknowledge the response you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.
kh, the SUBSTITUTE would cause issues if a 0 occurs elsewhere
Another variation on the theme might be:
B1: =REPLACE(A1,1,1,44)
assumes left most char is always a 0
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
ahh! very true thanks for pointing that out.
Please acknowledge the response you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.
You could just add a 1 to the SUBSTITUTE as optional 4th parameter though...
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
yes I just tested it like so--> =SUBSTITUTE(A1,0,44,1)
Please acknowledge the response you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.
SUBSTITUTE is an appropriate approach.
but you can also use the command "Text to Columns..." in menu Data
if you choose "fixed width" option, you can separate the first "0" from the rest of the digits.
then you can join them with "44" with operator "&"
probably in this case this is not the simplest way, but sometimes for some reasons you can't use formulas, and then this method will help
Perfect many thanks!! legend.
I went down the =SUBSTITUTE(A1,0,44,1) route which worked a dream. Thanks for all your suggestions. There replace functin as mentioned sometimes removed all the "0's".
Many thanks all.
I'm glad you've resolved but just to clarify:
The REPLACE Worksheet Function as illustrated would only ever replace the first character of the number... if you were running the Edit -> Replace Tool (via Menus) then yes that would replace all 0's.Originally Posted by pdiminski
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks