+ Reply to Thread
Results 1 to 13 of 13

Find and replace 61 at the start of numbers but not within

  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    Queensland, Australia
    MS-Off Ver
    MS365, Version 2202
    Posts
    73

    Find and replace 61 at the start of numbers but not within

    Hi Guys,

    I have a phone bill I'm trying to audit, for some reason mobile numbers are sometimes presented as #### ### ###, other times as +61### ### ###, other times 61### ### ###. I suspect this represents the actual dialed number, but thats not really important.

    I want to clean up the prefixes so I can use a VLOOKUP function to identify the numbers, but to do this, the numbers need to be in a standard format, which I would like to be the #### ### ### format. (it will actually be ### ### ### because the program I use to export the data to excel removes the leading 0, which no amount of formating in excel will return. I suppose I could manually add, or even write a macro to add it, but I can also just adjust my VLOOKUP database as a once off and never worry about it ever again).

    getting rid of the +61 is easy. Find all replace all "+61" with "blank". When I do this for "61" it finds 61 at the start of the number, but also within the number. I initially got around this by telling it to find all "61*********" but when I replace all with "blank" it deletes the number entirely, I suspect because of the asterix's....asterii?.....whatever. But without the asterixesesesii it will find and replace 61 within the number as well!

    Help please?

    Thanks guys!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Find and replace 61 at the start of numbers but not within

    got some samples in an excel work book ,formatting only changes the appearance not the underlying number
    eg
    666666 formated ## ## ## will give 66 66 66 but its still 666666 but if the cell is formated text first you can type 66 66 66 and its not the same thing
    and those that loose the leading 0 are probably formatted as numbers. so a few of each will do
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    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

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Find and replace 61 at the start of numbers but not within

    You could do it with a formula. Assume your numbers are in column A, then insert a new column B and put this formula in B2:

    =IF(LEFT(SUBSTITUTE(A2,"+",""),2)="61",RIGHT(SUBSTITUTE(A2,"+",""),LEN(SUBSTITUTE(A2,"+",""))-2,A2)

    then copy this down. Then fix the values, and then you can delete column A to leave you with the same layout as you started with.

    Hope this helps.

    Pete

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Find and replace 61 at the start of numbers but not within

    Please attach a sample file.
    Cheers!
    Deep Dave

  5. #5
    Registered User
    Join Date
    10-16-2013
    Location
    Queensland, Australia
    MS-Off Ver
    MS365, Version 2202
    Posts
    73

    Re: Find and replace 61 at the start of numbers but not within

    Quote Originally Posted by martindwilson View Post
    and those that loose the leading 0 are probably formatted as numbers. so a few of each will do
    I initially thought the same, but they are already formatted as numbers, the program that exports the data literally does not record a leading 0

    Quote Originally Posted by Pete_UK View Post
    =IF(LEFT(SUBSTITUTE(A2,"+",""),2)="61",RIGHT(SUBSTITUTE(A2,"+",""),LEN(SUBSTITUTE(A2,"+",""))-2,A2)
    The problem with this approach is that I have 305 individual worksheets, each of which represents an individual phone bill. I already have the macro that for each worksheet, it selects the right column, finds things such as MNET, MNE, +61 and deletes them (well, replaces them with 'blank'), but that works because those values are only at the start, or end, of the number, never in the middle. when I run the macro for find replace 61 it works at the start, but also removes 61 if it appears within the middle of the number as well

    Quote Originally Posted by msexcelathome View Post
    Please attach a sample file.
    will spoof one up now. Can't use the real data as the phone numbers are sensitive

  6. #6
    Registered User
    Join Date
    10-16-2013
    Location
    Queensland, Australia
    MS-Off Ver
    MS365, Version 2202
    Posts
    73

    Re: Find and replace 61 at the start of numbers but not within


  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Find and replace 61 at the start of numbers but not within

    Would =RIGHT(A1,9) do what you want?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Registered User
    Join Date
    10-16-2013
    Location
    Queensland, Australia
    MS-Off Ver
    MS365, Version 2202
    Posts
    73

    Re: Find and replace 61 at the start of numbers but not within

    Thanks for the attempts guys, but for the volume of data I'm dealing with these solutions didn't really work. I'd give you a copy of the data, but spoofing it would take days and its all sensitive company info.

    i've decided to just 'double up' my identities in the vlookup database, and present both the 61######### number and the ######### number. This is likely considered a 'kludge' in programming circles, but as illerate as I am in programming, my boss is even less so, so my kludge is likely to go unnoticed and unlikely to hurt anyone/thing other than the CPU that has to run through a double length VLOOKUP table :P

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Find and replace 61 at the start of numbers but not within

    Pl see the attached file.
    Instead of using VOOKUP formula you can use the ARRAY formula given in file.There is no need of altering your original Database.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Find and replace 61 at the start of numbers but not within

    Try removing the + and use this =IF(AND(LEFT(A8,2)="61",LEN(A8)=11),"0"&RIGHT(A8,9),"")

  11. #11
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Find and replace 61 at the start of numbers but not within

    I downloaded your xlsm (Numbers example ans.xlsm‎) but do not understand the formula. Can you break it down further (for the dummies) i.e. column a has numbers step one ??? step two ????
    Do you need to anything to settings & does the formula work in office 2007 and 2010?

  12. #12
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Find and replace 61 at the start of numbers but not within

    Pl see attached file.
    how to enter array formula
    paste the formula
    press F2
    Press Ctrl+Shift+Enter keys together
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 06-19-2014 at 01:44 AM.

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Find and replace 61 at the start of numbers but not within

    alternative to that is a simpler
    =IF(F1="","",LOOKUP(10^99,SEARCH($F1,$A$1:$A$9),B$1:B$9))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Automatically find and replace texts and numbers
    By a_27826 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-19-2013, 01:22 PM
  2. [SOLVED] Help to find a formula that replace numbers
    By JohnnyWalker in forum Excel General
    Replies: 6
    Last Post: 11-12-2012, 10:25 AM
  3. Replies: 1
    Last Post: 12-13-2011, 08:58 AM
  4. Find & Replace on Character numbers
    By SHS in forum Excel General
    Replies: 8
    Last Post: 08-10-2009, 10:32 AM
  5. [SOLVED] Find/Replace 4 numbers in a sting of 17
    By Lisa in forum Excel General
    Replies: 5
    Last Post: 01-05-2005, 07:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1