Macro to format time within a report

I need a macro to format dates in two columns to read as such "3/8/15 11:58". I'm looking to format the "Date Created" column as well as the "Last Updated" column. I would like for this to occur in the 'Import' tab (these columns are H and I).
Report.xlsx
AckeemKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try
Sub macro()

For Each sh In ActiveWorkbook.Sheets
    sh.Activate
    If sh.Name = "Current" Or sh.Name = "Import" Then
        For Each c In Range(Range("H2"), Range("I" & Cells.Rows.Count).End(xlUp))
            Debug.Print c.Address
            If Not IsDate(c) And c <> "" Then
                arrData = Split(c.Text, "-")
                arrTime = Split(Right(arrData(2), 8), ":")
                theDate = DateSerial(arrData(0), arrData(1), Left(arrData(2), 2))
                theTime = TimeSerial(arrTime(0), arrTime(1), arrTime(2))
                theDateTime = theDate + theTime
                c.Value = theDateTime
            End If
            c.NumberFormat = "mm\/dd\/yyyy hh:mm"
        Next
    End If
Next
End Sub

Open in new window

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AckeemKAuthor Commented:
In line 10, I am receiving a error with this highlighted saying "Subscript out of range". Any thoughts?
0
Rgonzo1971Commented:
Could you send dummy file with error?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

AckeemKAuthor Commented:
Within the report, when I try to import the file by pressing "Import Report File(s)" on the 'Table of Contents' tab, I receive that error. I attached the report and a file to import to test it and see the error I am getting.
DSE-Carelog-Report.xlsm
emc-ticket-history-view-2015-03-31-1432-
0
Rgonzo1971Commented:
then try

Sub FormatTime()
For Each sh In ActiveWorkbook.Sheets
    sh.Activate
    If sh.Name = "Current" Or sh.Name = "Import" Then
        For Each c In Range(Range("H2"), Range("I" & Application.Max(2, Range("I" & Cells.Rows.Count).End(xlUp).Row)))
            Debug.Print c.Address
            If Not IsDate(c) And c <> "" Then
                arrData = Split(c.Text, "-")
                arrTime = Split(Right(arrData(2), 8), ":")
                theDate = DateSerial(arrData(0), arrData(1), Left(arrData(2), 2))
                theTime = TimeSerial(arrTime(0), arrTime(1), arrTime(2))
                theDateTime = theDate + theTime
                c.Value = theDateTime
            End If
            c.NumberFormat = "mm\/dd\/yyyy hh:mm"
        Next
    End If
Next
compare
End Sub

Open in new window

0
AckeemKAuthor Commented:
Thank you, this worked perfectly.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.