+ Reply to Thread
Results 1 to 11 of 11

Macro to insert "+" character before a number

  1. #1
    Registered User
    Join Date
    08-25-2009
    Location
    Canberra
    MS-Off Ver
    Excel 2003
    Posts
    4

    Macro to insert "+" character before a number

    Hi,

    I have searched this and other forums for a macro which will insert a "+" (international dialling prefix) character before a phone number in an Excel field with no success. I have tried the "record macro" function without success. Any ideas?

    Thanks.
    Last edited by schtumpster; 08-26-2009 at 07:46 AM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Macro to insert "+" character before a number

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Macro to insert "+" character before a number

    If Excel considers the entry in the cell is a number it will remove the + symbol
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro to insert "+" character before a number

    Another alternative might be to apply a Custom Format to those cells containing the numbers, ie: +#;;;+@

    The above would not physically alter the values but would display and print the + operator.

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Macro to insert "+" character before a number

    If Excel considers the entry in the cell is a number it will remove the + symbol
    I am forcing the entry to text by prepending the "+" character with the single quote - so it will add the character but convert the cell content to text.

  6. #6
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Re: Macro to insert "+" character before a number

    Quote Originally Posted by schtumpster View Post
    I have searched this and other forums for a macro which will insert a "+" (international dialling prefix) character before a phone number in an Excel field with no success. I have tried the "record macro" function without success. Any ideas?
    Not to step on anybody's toes, but what's the goal here? Why do you want the + symbol to show up? Are all the items in the range international phone numbers?

    If it's just a display issue, DonkeyOte has the right answer. Special number formats are your friend. I use them quite extensively when I want to mix text into a cell with numbers, but still be able to use the number as part of calculations.

    If you actually need to do something else with the number, it can get more complicated.

  7. #7
    Registered User
    Join Date
    08-25-2009
    Location
    Canberra
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to insert "+" character before a number

    Thanks for the replies so far.

    Donkey,

    It's not just a display requirement. I'd like the character "+" to be the first character of the field, followed by the phone number. I don't think it matters if it is text or a number, although maybe it should be just text as Mudraker states.

    Timothy,

    I need the "+" as I am going to export the data into Outlook, then for synchronisation with a Nokia phone. The end result is that all numbers in my phone are preceeded by a "+"<county code> so that I can dial them from anywhere internationally. I presently have the field as needed (including country codes), now just need the "+". There are a few hundred numbers so trying to avoid doing it manually.

    Palmetto,

    Thanks for the code, but it inserts a "+" infront of cell A1 only. I need it to run on any selected cell(s). Is this an easy mod?

    Cheers!

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro to insert "+" character before a number

    I need it to run on any selected cell(s).
    Please Login or Register  to view this content.
    Last edited by shg; 08-25-2009 at 08:13 PM. Reason: simplify
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    08-25-2009
    Location
    Canberra
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to insert "+" character before a number

    thanks SHG, this works fine. I will check that the export to Outlook and Sync with Nokia phone is successful and post again later.

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

    Re: Macro to insert "+" character before a number

    can you export a csv to outlook? beacause when its in csv format the custom format donkeyote suggested is maintained in the csv
    see attached text a renamed csv which was formatted to add +
    Attached Files Attached Files
    "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

  11. #11
    Registered User
    Join Date
    08-25-2009
    Location
    Canberra
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to insert "+" character before a number

    Thanks all - worked fine through the import to Outlook and Sync with Nokia.

    Martin - I had a little bit of other editing to do so excel worked better for me than csv, but thanks for the info.

    Cheers!

+ 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