+ Reply to Thread
Results 1 to 15 of 15

Formatting Phone and Celular Numbers

  1. #1
    Registered User
    Join Date
    10-05-2012
    Location
    Sint-Niklaas, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    14

    Formatting Phone and Celular Numbers

    Hello,

    I'm trying to modify the following function for formatting Phone numbers to serve my needs:

    Please Login or Register  to view this content.
    This is the code I came up with but it doesn't work properly. Instead of correcting numbers in column L it deletes all cells. The numbers starts all with "0" and are formatted as text. Please, share some ideas on improving this code:
    Please Login or Register  to view this content.
    Thanks in advance,
    Andrei
    Last edited by Andrei Kononenko; 11-06-2012 at 05:31 AM.

  2. #2
    Forum Contributor
    Join Date
    08-09-2012
    Location
    Anch, Alaska
    MS-Off Ver
    2003, 2010, 2013
    Posts
    131

    Re: Formatting Phone and Celular Numbers

    Andrei,

    Try this


    Please Login or Register  to view this content.
    Give Credit When Credit Is Due - Click On the Star
    Be Sure To Mark Your Post [Solved] When You Get Your Answer

  3. #3
    Registered User
    Join Date
    10-05-2012
    Location
    Sint-Niklaas, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Formatting Phone and Celular Numbers

    Hi Bucko,

    Your sollution works brilliantly! I was just wandering what RowCnt = 2 did exactly and what 12 in Cells(RowCnt, 12) stood for. Can you elaborate a bit on these two questions?

    In any case, thanks a lot for your assistance!

    Regards,
    Andrei

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Formatting Phone and Celular Numbers

    Why not just format the cells, why do it in code?

  5. #5
    Registered User
    Join Date
    10-05-2012
    Location
    Sint-Niklaas, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Formatting Phone and Celular Numbers

    And that... is a good question, Kyle! How can I format the cells for both mobile and phone numbers just by selecting the column once?

    Regards,
    Andrei

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Formatting Phone and Celular Numbers

    Use conditional formatting, test if the cell > 100000000

  7. #7
    Registered User
    Join Date
    10-05-2012
    Location
    Sint-Niklaas, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Formatting Phone and Celular Numbers

    Well, I think there might be a problem with CF in my case. Besides digits the cells contain other characters such as commas, brackets, dashes and "abc"-characters. The whole idea is to extract digits from a string of characters and format these digits as phone and celular numbers. (E.g. L2 = "03 7774684, [email protected]" --> 03 777 46 84)
    Please, correct me if I think incorrectly but your sollution implies that the cells are formatted as values not as text and the first digit must be higher of equal to 1.

    Regards,
    Andrei

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Formatting Phone and Celular Numbers

    Yes, you're right

    The only thing to consider with your cleaning function is that id there are any numbers in the email address, they will be added to the phone number

  9. #9
    Registered User
    Join Date
    10-05-2012
    Location
    Sint-Niklaas, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Formatting Phone and Celular Numbers

    Jesus Christ and his mother Mary, I haven't even considered this possibility. Any idea's on how I can select the first 9 digits if second digit is 3 or 9 and 10 digits if second digit is 4 ? (03 XXX XX XX and 04XX XX XX XX)

    Regards,
    Andrei

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Formatting Phone and Celular Numbers

    Can you give some examples of the data you have to deal with? Just trying to see if there are consistent themes or whether the data is all inconsistent and a mess

  11. #11
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Formatting Phone and Celular Numbers

    Actually, try this function
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    10-05-2012
    Location
    Sint-Niklaas, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Formatting Phone and Celular Numbers

    This is an example of the data, Kyle. The data is quite inconsistent as you can see.

    I was wandering whether it would be possible to delete everything after the first comma and use CF for the formatting?
    I'm trying to avoid functions and public functions as I'll have to explain to unexperienced excel users how to use my macros when I'm out of the office.

    I sincerely appreciate your effort, Kyle

    regards,
    Andrei
    Attached Files Attached Files

  13. #13
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Formatting Phone and Celular Numbers

    This worked for me for all your examples (using conditional formatting)
    Please Login or Register  to view this content.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Formatting Phone and Celular Numbers

    See attached

    B2:
    Format cell as Wrap Text
    =FormatPhone(A2,CHAR(10))
    then copy down
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jindon; 11-07-2012 at 01:10 PM.

  15. #15
    Registered User
    Join Date
    10-05-2012
    Location
    Sint-Niklaas, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Formatting Phone and Celular Numbers

    @ Kyle Your sollution works great! You have been really helpful in my thread. Thanks a lot for that. Unfortunatelly, I can't give you more reputation points in this thread otherwise I would give you 1000 EXP Thanks again.
    @Jindon Your function is a piece of programming art. Thanks for your effort as well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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