+ Reply to Thread
Results 1 to 13 of 13

Macro to copy numbers as texts by adding an apostrophe in front of the numbers

  1. #1
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    In Column D, I have a series of numbers.

    Column B is the same series of numbers but converted to texts by adding an apostrophe in front of the numbers.

    I need a macro to copy the numbers in Column D to Column B and add an apostrophe in front of the numbers in column B.

    Macro to start from row 2 and to stop when it encounters 2 consecutive empty rows.

    Thanks in advance.

    Joseph

    Convert numbers to texts.png
    Last edited by josephteh; 08-23-2017 at 11:31 PM.

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

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    The macro works perfectly! Thanks jindon!

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

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    You are welcome and thanks for the rep.

  5. #5
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Wait.... if the numbers are in the five digits, the macro does not work!

    Can the macro be modified to convert any numbers with any number of digits?

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

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Should work for any digits.

  7. #7
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Aye... it was not working well... but after I saved and closed the file and re-opened it... the macro is working! Thanks jindon!

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Dear jindon... would you be kind to explain to me what is the "4" for and what does the following statement do?

    "In Columns("d").SpecialCells(4).Areas"

    Thank you.

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

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    While you are in vbe
    [view] - [Object Browser] then type xlspecialcells in search box.
    Click on XLCellType in the bottom pane within the Function.
    Click on xlCellTypeBlanks and you will see the value in the bottom pane showing "Const xlCellTypeBlanks = 4"

    Areas:
    Just highlight Areas and hit F1.
    You will see the help.

  10. #10
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Quote Originally Posted by jindon View Post
    While you are in vbe
    [view] - [Object Browser] then type xlspecialcells in search box.
    Click on XLCellType in the bottom pane within the Function.
    Click on xlCellTypeBlanks and you will see the value in the bottom pane showing "Const xlCellTypeBlanks = 4"

    Areas:
    Just highlight Areas and hit F1.
    You will see the help.
    Thanks for pointing me to the place to see help.. I still blur blur...

    The macro seems not to work when I added more numbers to the list... please see attached file below. Please help! Thanks.

  11. #11
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Wait... now it seems to work... is the macro a bit unstable or is it my Excel version?

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

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Perhaps only your Excel...

  13. #13
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Macro to copy numbers as texts by adding an apostrophe in front of the numbers

    Ya.. most likely... thanks jindon!

+ 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. Adding Same Characters In Front Of and Behind a Column of Numbers
    By jrstites in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-08-2014, 11:49 AM
  2. Replies: 2
    Last Post: 01-07-2014, 04:34 AM
  3. Adding numbers with USD in front
    By IamRustyP in forum Excel General
    Replies: 7
    Last Post: 04-11-2011, 03:53 PM
  4. Adding a zero in front of list of numbers
    By jennyc1216 in forum Excel General
    Replies: 5
    Last Post: 11-04-2010, 12:41 PM
  5. Adding 0. in front of numbers
    By WHUMad in forum Excel General
    Replies: 1
    Last Post: 06-06-2007, 05:58 AM
  6. [SOLVED] Adding a 0 in front of a column of numbers
    By scasawyer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2005, 10:05 AM
  7. [SOLVED] adding digits to front/end of fax numbers
    By Luke in forum Excel General
    Replies: 2
    Last Post: 04-27-2005, 07:06 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