+ Reply to Thread
Results 1 to 4 of 4

Adding a Prefix 0 to column using macros

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    texas, United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Exclamation Adding a Prefix 0 to column using macros

    Hey Guys, I'm stumped.

    Hey Guys,

    I have this program which I'm attempting to export to excel but the values, i.e. (hh:mm [2:15], [:50]), can only come through only as text format so that the values don't change even though the format is the same. I attempted to change the formats but unfortunately, whatever was imported stay as text. I found out that if I add a "0" in front of these entries and change the format to [hh:mm] it can work but 500+ files are to many to change manually so I entered the following macro but it only changes the first cell. If anybody can revise the following code so that the range is from e1:e700.

    Thank You,

    Please Login or Register  to view this content.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Adding a Prefix 0 to column using macros

    The first thing I'd suggest you do is to select the affected range then use Excel's cell formatting to change the format to 'Time'. Then, in any used cell, insert the number '1'. Copy the cell then re-selct your 'time' range and use Paste Special > Values > Multiply. That should be sufficient to convert any 'text' times to formatted timevalues.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    texas, United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Exclamation Re: Adding a Prefix 0 to column using macros

    Thanks Macropod,

    The only thing is that there are some cells that got exported but since they didn't have any hours they were exported as, i.e. (:50). The formatting that you gave me turns the ones with hours, i.e. (1:50) into actual time but since the ones that don't have hours don't have a zero in front of it, I guess it still doesn't recognize it as time. Which is why I was looking into macros to automatically add a prefix of a zero and the code that i have works but for some reason only does the 1st row.

    Thank You

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Adding a Prefix 0 to column using macros

    That suggests the affected cells are only formatted as ':ss' or ':mm'. You should format all of them the same way, ie: 'hh:mm:ss', or 'hh:mm' or 'mm:ss'.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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