Cleaning data

Tracemark

New Member
Joined
May 15, 2014
Messages
26
I have data which appears as: 447596125369
44 appears in all cells
I need to replace 44 with 0 and add a space to result in 07596 125369

I have 500,000 records so find / replace is not an option

Can anyone help?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I have data which appears as: 447596125369
44 appears in all cells
I need to replace 44 with 0 and add a space to result in 07596 125369

I have 500,000 records so find / replace is not an option
1) Does the 44 that you want to replace always appear at the beginning of the number?

2) Are the numbers that you want to change always 12 digits long?

3) Can we assume the cells your numbers are in are formatted as Text?

4) Can you make use of a macro to change the number within its own cell or are you looking for a formula to display the changed value in a different cell.
 
Upvote 0
Why is Find /Replace not an option ??
 
Upvote 0
How about you format it as international format? Use custom number format as: +00 0000 000000

To replace the "44" you could use this:
Code:
selection.value=evaluate("if(row(),mid(" & selection.address & ",3,255))")
1. Select the range of telephone numbers
2. Go to the VBE (ALT+F11)
3. Go to the Immediate Window (Control+G)
4. Paste the code above
5. Hit Enter
6 Format the range as: 00000 000000
 
Upvote 0
To answer your questions:
1. Yes
2. Yes
3. Yes
4. I am not familiar with the use of macros but would prefer to change the number in its own cell

44 could appear in other locations
 
Upvote 0
Yeah, sorry Rick, your post hadn't appeared when I posted !!!
 
Upvote 0
This leaves me with numbers showing just the last 6 digits

This is my first post.

I appreciate the time you are giving and the speed of the replies.
 
Last edited:
Upvote 0
Give this macro a try (change the red highlighted text to the address for your actual range of cells)...
Code:
Sub Replace44With0InsertSpace()
  Dim R As Long, C As Long, Nums As Variant
  Const RangeWithNumbers As String = "[COLOR=#ff0000][B]A1:C16[/B][/COLOR]"
  Nums = Range(RangeWithNumbers)
  For R = 1 To UBound(Nums)
    For C = 1 To UBound(Nums, 2)
      If Len(Nums(R, C)) Then
        Mid(Nums(R, C), 1) = " 0"
        Nums(R, C) = Format(Trim(Nums(R, C)), "00000 000000")
      End If
    Next
  Next
  Range(RangeWithNumbers) = Nums
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Replace44With0InsertSpace) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this action again later on and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook; otherwise, just save your file as normal (the macro will be deleted from the workbook when you save it a you normally would).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,857
Messages
6,121,948
Members
449,056
Latest member
FreeCricketId

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top