Solved

how to Update a field in excel

Posted on 2009-05-10
4
218 Views
Last Modified: 2012-05-06
I have a whole list of mobile phone numbers that were given with spaces etc in them and some that are not.  i have removed the spaces. but need to put a 0 in front of the number

ie 402130163

needs to be 0402130163

Cannot think today have the flue can someone plesae asist.
0
Comment
Question by:Amanda Walshaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 57

Assisted Solution

by:giltjr
giltjr earned 100 total points
ID: 24350819
First thing that pops into my mind as a quick and dirty is to insert a column in front of the phone number, fill with 0, and then merge the two columns.
0
 
LVL 25

Assisted Solution

by:lwadwell
lwadwell earned 100 total points
ID: 24350841
Hi Flyfishtrout15,

you can change the field format to 0000000000 or add another column with the formula =text(a1,"0000000000")

lwadwell
0
 

Accepted Solution

by:
dashahz earned 200 total points
ID: 24350871
There's a couple of ways to do this, but here's one:

1. Go to a free column
2. Let's say that the first phone number exists B1.  So in the new column, type in:
=("0"&B1)

This will combine "0" with whatever is in B1.

3. Now, extend this formula down to the end of the the phone number list.

Here are some references:
http://office.microsoft.com/en-us/excel/HP052510211033.aspx#MergeCellContents
http://office.microsoft.com/en-us/excel/HP052090201033.aspx
0
 
LVL 50

Assisted Solution

by:Dave Brett
Dave Brett earned 100 total points
ID: 24350890
This code will quickly update your current numbers insitu - so you won't have to copy and paste other cells back over your originals manually
to use
'Press Alt + F11 to open the Visual Basic Editor (VBE)
'From the Menu, choose Insert-Module.
'Paste the code into the right-hand code window.
'Press Alt + F11 to close the VBE
' Select your cells
'Go to Tools & Macro & Macros and double-click Clearer
 
Cheers
Dave

Sub Clearer()
    Dim rng1 As Range, rngArea As Range, i As Long, j As Long
    Dim X()
    Dim AppCalc As Long
 
    'code runs on the active selection
    Set rng1 = Selection
  
 
    With Application
        AppCalc = .Calculation
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
 
    For Each rngArea In rng1.Areas
    rngArea.NumberFormat = "@"
        If rngArea.Cells.Count > 1 Then
            X = rngArea
            For i = 1 To rngArea.Rows.Count
                For j = 1 To rngArea.Columns.Count
                    X(i, j) = "0" & X(i, j)
                Next j
            Next i
            rngArea = X
        Else
            rngArea.Value = "0" & rngArea
        End If
    Next rngArea
 
    With Application
        .ScreenUpdating = True
        .Calculation = AppCalc
    End With
End Sub

Open in new window

0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question