I've tweaked your code a bit to do the sums
If Range("E2") = "PM" Then
theValue1 = Range("C2").Value + 12 + Range("D2").Value / 60
Else
theValue1 = Range("C2").Value + Range("D2").Value / 60
End If
A simpler way would be
theValue1 = Range("C2").Value + Range("D2").Value / 60
If Range("E2") = "PM" Then theValue1 = theValue1 + 12
To make the application more user friendly, I've added a sheetchange event. Basically, it checks if you have selected a cell in column I and if there is data (AM/PM) in column H, it will do the time calculation and enter the result in Column K. The Cell references are changed to "offsets" as the code needs to be more flexible. The code is stored in Sheet1(Timesheet) rather than in a standard module.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim theValue As Double, theValue1 As Double, theValue2 As Double
If Target.Column() = 9 And ActiveCell.Offset(0, -1) <> "" Then
theValue1 = ActiveCell.Offset(0, -6).Value + ActiveCell.Offset(0, -5).Value / 60
If ActiveCell.Offset(0, -4) = "PM" Then
theValue1 = theValue1 + 12
End If
theValue2 = ActiveCell.Offset(0, -3).Value + ActiveCell.Offset(0, -2).Value / 60
If ActiveCell.Offset(0, -1) = "PM" Then
theValue2 = theValue2 + 12
End If
theValue = theValue2 - theValue1
ActiveCell.Offset(0, 2) = theValue
End If
End Sub
Good luck with the learning!
MD