+ Reply to Thread
Results 1 to 3 of 3

Converting to time

  1. #1
    Registered User
    Join Date
    04-20-2004
    Posts
    2

    Converting to time

    Hello!

    I regularly import data into an excel sheet, the time column I receive is in the following format:

    839
    603
    1154
    1336
    734

    which is:
    08:39
    06:03
    11:54
    13:36
    07:34


    What macro can I use to convert this column into a time format?


    Thanks for your help.

    M.E.

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    Sub convert_date()
    Dim i As Long
    Dim temp as variant
    For i = Range("A65536").End(xlUp).Row To 1 Step -1
    if len(cells(i,1).value)=3 then
    temp = "0" & Mid(Cells(i, 1), 1,1 ) & ":" & mid(cells(i,1),2,2)
    elseif len(cells(i,1).value)=4 then
    temp = Mid(Cells(i, 1), 1,2 ) & ":" & mid(cells(i,1),3,2)
    end if

    Cells(i, 1).NumberFormat = "dd mmm yyyy"
    Cells(i, 1).Value = temp
    Next
    End Sub

  3. #3
    Registered User
    Join Date
    04-20-2004
    Posts
    2
    Thank you!
    I adapted it to my spreadsheet and it worked.

+ 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