+ Reply to Thread
Results 1 to 10 of 10

Phone Format - change value.

  1. #1
    Registered User
    Join Date
    01-14-2008
    Posts
    18

    Phone Format - change value.

    PHONE formatting. Is there a way to create a macro to format the VALUE of the phone to be either (XXX) XXX-XXX or XXX-XXX-XXXX ??? I obviously can get it to look like this, but the value is just XXXXXXXXXX.


    Thanks much in advance!!!

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon jreimer

    Quote Originally Posted by jreimer
    Is there a way to create a macro to format the VALUE of the phone to be either (XXX) XXX-XXX or XXX-XXX-XXXX ???
    You don't need to use a macro - just use a custom format.
    Select your cell / range.
    Press Ctrl + 1.
    On the number tab, goto Custom in the Category box and type one of the below into the box marked Type :

    (###) ### ####
    ###-###-####


    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    01-14-2008
    Posts
    18

    Post

    that gives me the same issue - it looks correct, but the value is still XXXXXXXXXX.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi jreimer

    Quote Originally Posted by jreimer
    it looks correct
    If it looks correct then what's the problem? Can you elaborate?

    DominicB

  5. #5
    Registered User
    Join Date
    01-14-2008
    Posts
    18
    the value of the cell is still XXXXXXXXXX not (XXX) XXX-XXXX - the format is just (XXX) XXX-XXXX - so it looks all nice and pretty, but the value of the cells is not the same.

    In the cell - it looks like (XXX) XXX-XXXX, but if you click on the cell, in the bar to edit its contents - its XXXXXXXXXX (incorrect).

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi jreimer

    OK. Highlight the range you want to address and then run this macro :

    Please Login or Register  to view this content.
    Note, you can change the ###-###-#### to (###) ### #### to suit whichever format you prefer.


    HTH

    DominicB

  7. #7
    Registered User
    Join Date
    01-14-2008
    Posts
    18
    That works! Beautiful!

    Thanks

  8. #8
    Registered User
    Join Date
    01-14-2008
    Posts
    18
    Well, it does work - however, when I select a column it just keeps going and going - i have to select the specific cells for it to end.

    Can this be modified to work with a column selection?

  9. #9
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi jreimer

    Quote Originally Posted by jreimer
    Can this be modified to work with a column selection?
    Yes, but I've never seen your data so I'm working blind to a degree here, but have a go with this :
    Please Login or Register  to view this content.
    This code assumes that your numbers start on row 4, and the code will go down to the end of whichever column you are in and do its stuff. You may have further requirements - if you do you may have to post a portion of your workbook so I can see how your data is structured. Let me know how you go on.

    HTH

    DominicB

  10. #10
    Registered User
    Join Date
    01-14-2008
    Posts
    18
    Okay, this is working much better.

    It doesn't continue to run and run. However, I do have some questions about the code itself.

    Please Login or Register  to view this content.
    The first line:
    rc = Cells(65536, ActiveCell.Column).End(xlUp).Row

    does this mean that it will ONLY run through 65,546 rows? This SHOULDN"T be a problem for 99.999999% of my spreadsheets - however, who knows when there will be one with more than that! I just want to know how the code works.

    Also - There are times when I want to run this over multiple columns (phone AND fax) - I'm getting weird quirks when I do it over two columns. Like it will run through one column, not the other - then I run it again, and it runs it over the other columns, and changes the first one back... not really sure. Just wanted to check with you if this is MADE for just one column and if there's a way to do multiple columns.

+ 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