+ Reply to Thread
Results 1 to 3 of 3

Change Data into Times via macro...

  1. #1
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Change Data into Times via macro...

    How is the best way to change my data into a time.. I have no idea how to do this

    Raw Data:
    Please Login or Register  to view this content.

    The end result I want is:
    Please Login or Register  to view this content.
    Last edited by Hyflex; 09-27-2011 at 05:08 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Change Data into Times via macro...

    Not sure you'd need code, but in code i'd do
    Function convert_time(strTime As String) As Date

    Dim intHours As Integer
    Dim intMins As Integer
    Dim intDividerLocation As Integer
    Dim intStringLength As Integer

    intDividerLocation = InStr(1, strTime, ":")
    intStringLength = Len(strTime)

    intHours = CInt(Mid(strTime, 1, intDividerLocation - 1))
    intMins = CInt(Mid(strTime, intDividerLocation + 1, (Len(strTime) - intDividerLocation)))

    convert_time = TimeSerial(intHours, intMins, 0)

    End Function

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Change Data into Times via macro...

    Hyflex,

    Formula solution:
    =TEXT(SUBSTITUTE(A1,"-",":")&" pm","hh:mm")

    And then you can Copy -> Paste Special -> Values.

    If you need VBA, you can convert all items at once using the below code. Just change DataCol to be the column (or columns) that contain the raw data you want to convert:
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

+ 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