Looking for a way to convert data in an Excel cell to consistent information.

I'm pulling reports from a Learning Management System on training completions.  While my team is working on modifying the backend information to deliver consistent data, I still need to report on current data coming out.  I have a column labeled "Training Duration".  The data currently being delivered can be in either Minutes or Hours.  An example of each is below:

0.75 Hours
30.00 Minutes

I'd like to examine the cell and convert all of them to A) Hours and B) a cell with just the actual time listed.  The above examples would then be turned into the following:


Is this a VB script problem?  Is there some formula in Excel that would allow me to do this?  Any assistance, suggestions or recommendations are appreciated.

An example of the data file  is attached. The column in question is highlighted.C--Users-06596.GLOBAL-Desktop-16010.xlsx
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.


pls try
=IF(RIGHT(I2,5)="Hours",LEFT(I2,SEARCH(" ",I2)-1),IF(RIGHT(I2,7)="Minutes",TEXT(VALUE(LEFT(I2,SEARCH(" ",I2)-1))/60,"0,00"),""))

Open in new window

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Or try this....
Sub ConvertDurations()
Dim lr As Long, i As Long
Dim x
lr = Cells(Rows.Count, "I").End(xlUp).Row
x = Range("I2:I" & lr).Value
For i = 1 To UBound(x)
   If InStr(x(i, 1), "Hours") > 0 Then
      x(i, 1) = Trim(Replace(x(i, 1), "Hours", "")) + 0
   ElseIf InStr(x(i, 1), "Minutes") > 0 Then
      x(i, 1) = Round(Trim(Replace(x(i, 1), "Minutes", "")) / 60, 2)
   End If
Next i
Range("I2").Resize(UBound(x), 1).Value = x
End Sub

Open in new window


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
MMacyginAuthor Commented:
This was the solution I needed.  Handled the column flawlessly.  I so appreciate the quick response and solution.
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Glad to know that the solution worked as per your expectations.
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.