hhalyami43
04-05-2020, 02:18 AM
Greetings,
basically I created this code for maintenance team to record data of machine breakdown
I'm trying run the following code but it keeps give me error msg (run time error '13' mistype) when i run it
first I want to add start time and end time will blank until the machine got repaired then update end time and applying the following formula:
duration(I)= end time(H) - start time(G)
so I need your help
Thanks in advance!
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
sh.Range("G" & last_Row + 1).Value = TextBox4.Value & " " & ComboBox4.Value 'start in format (mm/dd/yyyy hh:mm)
sh.Range("H" & last_Row + 1).Value = TextBox5.Value & " " & ComboBox5.Value 'end in format (mm/dd/yyyy hh:mm)
If sh.Range("H" & last_Row + 1).Value < sh.Range("G" & last_Row + 1).Value Then 'Error msg when negative value
MsgBox "End breakdown must be bigger than start breakdown", vbCritical
Exit Sub
End If
If sh.Range("H" & last_Row + 1).Value = "" Then
sh.Range("I" & last_Row + 1).Value = ""
Else
sh.Range("I" & last_Row + 1).Value = sh.Range("H" & last_Row + 1).Value - sh.Range("G" & last_Row + 1).Value
End If
basically I created this code for maintenance team to record data of machine breakdown
I'm trying run the following code but it keeps give me error msg (run time error '13' mistype) when i run it
first I want to add start time and end time will blank until the machine got repaired then update end time and applying the following formula:
duration(I)= end time(H) - start time(G)
so I need your help
Thanks in advance!
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
sh.Range("G" & last_Row + 1).Value = TextBox4.Value & " " & ComboBox4.Value 'start in format (mm/dd/yyyy hh:mm)
sh.Range("H" & last_Row + 1).Value = TextBox5.Value & " " & ComboBox5.Value 'end in format (mm/dd/yyyy hh:mm)
If sh.Range("H" & last_Row + 1).Value < sh.Range("G" & last_Row + 1).Value Then 'Error msg when negative value
MsgBox "End breakdown must be bigger than start breakdown", vbCritical
Exit Sub
End If
If sh.Range("H" & last_Row + 1).Value = "" Then
sh.Range("I" & last_Row + 1).Value = ""
Else
sh.Range("I" & last_Row + 1).Value = sh.Range("H" & last_Row + 1).Value - sh.Range("G" & last_Row + 1).Value
End If