Receiving Error in Macro Function

I keep receiving a error in my reporting tool as I try to import a file pertaining to the "FormatTime" macro. Anyway I can fix this? I've attached the reporting tool (DSE Carelog Report) as well as the file I am trying to import. On the 'Table of Contents' tab within the DSE Carelog Report, you see it says "Import Report File(s)". From there, I select the file that is attached (SEARCH_SR_LIST.csv) and receive the error I was able to screenshot as well.
DSE-Carelog-Report-V2.xlsm
SEARCH-SR-LIST.csv
carelog-error.tiff
AckeemKAsked:
Who is Participating?
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.

GrahamSkanRetiredCommented:
This is the procedure that is shown in your picture:
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("I2"), Range("J" & 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
EE_ChangeOpenValues
End Sub

Open in new window


You indicate that the error is on the second of these two lines:
                arrData = Split(c.Text, "-")
                arrTime = Split(Right(arrData(2), 8), ":")

Open in new window


You don't say what the error is, but if it is 'Subscript out of range' then it is likely that the data in the range has less than two hyphens. You need to test for that possibility and take appropriate steps. This code will just stop the process, but you will probably want to do something else.
                arrData = Split(c.Text, "-")
                If UBound(arrData) < 2 Then
                    MsgBox "Data error"
                    End
                End If
                arrTime = Split(Right(arrData(2), 8), ":")

Open in new window

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
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
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
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.