+ Reply to Thread
Results 1 to 3 of 3

Macro to Format Cells into a String

  1. #1
    Forum Contributor 00Able's Avatar
    Join Date
    11-17-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    244

    Macro to Format Cells into a String

    Looking for assitance, I have 2 columns that need to be reformatted so that they can go into an access file.
    • Row R, needs to have 6 digits, and if the cells do not, they need to be proceeded by 0's
    • Row T, needs to have 9 digits, and if the cells do not, they need to be proceeded by 0's

    So in cell R2, if the value is 23de, then I need it to say 0023de
    in cell R3, if the value is 256, then I need it to say 000256

    So in cell T2, if the value is 123, then I need it to say 000000123
    in cell T3, if the value is 234567, then I need it to say 000234567

    but it needs to stay like this so it can go into an access database? A suggestion to one of my previous threads by MarvinP says to
    Please Login or Register  to view this content.
    will help with 8 digit long strings, so I assume, changing the 8 to a 9 will help, but my newly found concern is that it might be easier just to make a macro, as this task needs to be performed daily.
    Attached Files Attached Files
    Last edited by 00Able; 03-04-2011 at 07:27 PM.
    Providing Problems for Your Solutions
    STARS are my Punching Bag, You will be rewarded.

    In the rare event that I may help you, feel free to make me see STARS

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Macro to Format Cells into a String

    see the sample data in the attached file "ABLE"

    IMPORTANT- THE DATA IN SHEET1 IS COPIED IN SHEET 2 ALSO

    now run the macro "test" (to undo run macro "undo")

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    b
    Attached Files Attached Files

  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 Format Cells into a String

    @venkat1926, you might want to check out the String function in VBE which works in similar (not identical) fashion to the native REPT function

+ 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