+ Reply to Thread
Results 1 to 5 of 5

Leading Zeros To Specific Fields

  1. #1
    Registered User
    Join Date
    07-08-2008
    Location
    ny
    Posts
    14

    Leading Zeros To Specific Fields

    Hi,

    I am having a problem with excel. I have a program that exports data to my clipboard and then pasted into excel. The problem that comes up is that certain time fields will export as ":19:20". This is not a valid time format for excel. Is there a way to add zero's in front of these specific fields so that the result is "0:19:20".

    I need to perform average and sum functions on all these fields. I do not know how to use macros or do any vba, but I am able to follow step-by-step instructions on how to use these two options if it is the only way to correct my problem.

    Thanks

  2. #2
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi,

    If all these values are in column A, then

    =("00"&A1)*1
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try:


    =(0&A1)+0

    copied down, where A1 houses first one.

    you may have to format cells as Time (13:30:55)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    07-08-2008
    Location
    ny
    Posts
    14
    Quote Originally Posted by oldchippy
    Hi,

    If all these values are in column A, then

    =("00"&A1)*1
    This formula worked out nicely.

    Just wanted to ask this because I am curious and want to understand this formula, why the "*1" at the end. I noticed that if I took this out, fields will get changed to a non-time format.

  5. #5
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi,

    Because your number :19:20 isn't recognised as a number, Excel treats it as text, so the first part of the formula adds 00 to the text to become 00:19:20. So to convert that to a number when this is multiplied by 1, or as NBVC example +0 this does the trick.

+ 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