+ Reply to Thread
Results 1 to 7 of 7

Macro to append text to cell

  1. #1
    Registered User
    Join Date
    06-28-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Macro to append text to cell

    Hi,


    I am looking for a macro to convert a 6 digital serial number into an 8 digit serial number by adding "00" to the front. ie. The cell may say 123456, but I need to change it to display 00123456.

    Is there a simple way to do this?


    Thanks.
    Last edited by mcp21x; 07-10-2009 at 07:16 AM.

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Macro to append text to cell

    If you can place the value in the following column you can do the following:

    6 digit number in cell A1

    In cell B1 enter
    Please Login or Register  to view this content.
    You can then copy this down if needed
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

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

    Re: Macro to append text to cell

    Would a Custom Format suffice ?

    Highlight cells to which the 8 digit serial is to be applied and use a Format of : 00000000

    The underlying value remains 6 digits but will "appear" and be printed as an 8 digit value (populated with appropriate number of leading zeroes).

  4. #4
    Registered User
    Join Date
    06-28-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Macro to append text to cell

    Thanks for your help, but I need the value to be absolute and in the same column. Since posting, I have managed to come up with a solution. I've written it like this:
    Please Login or Register  to view this content.
    Last edited by mcp21x; 07-10-2009 at 06:09 AM.

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

    Re: Macro to append text to cell

    mcp21x

    Please take a couple of minutes and read ALL theForum Rules then wrap your VBA code (Rule 3)
    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.

  6. #6
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Macro to append text to cell

    Quote Originally Posted by mcp21x View Post
    Thanks for your help, but I need the value to be absolute and in the same column. Since posting, I have managed to come up with a solution. I've written it like this:
    Please Login or Register  to view this content.
    Ok, didn't realise you were looking for a VBA solution and you wanted your value in the same column.

    Your code could be condensed to this:

    Please Login or Register  to view this content.
    Do you require it to cycle through all the cells in column A or just apply it to your currently active cell?

  7. #7
    Registered User
    Join Date
    06-28-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Macro to append text to cell

    Your method is much better. I've only been fiddling with VBA for a couple of days so still have a lot to learn.

    This routine is a small component of a larger VBA script I am writing to convert an excel file generated from one program into another excel file with different format/column data requirements by another program. As a result I already have a loop procedure.

    Thanks again for your assistance.

+ 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