|
こんなでは?
Sub Test()
Dim strTime As String
Dim dtmTime As Date
Dim dtmResult As Date
strTime = InputBox("時刻を入力してください。hh.mm.ss", "時刻入力")
If strTime <> "" Then
If IsDate(strTime) Then
dtmTime = TimeValue(strTime)
dtmResult = dtmTime - #12:10:00 AM#
With Sheets("Sheet1")
With .Range("B1")
.NumberFormatLocal = "hh.mm.ss"
.Value = dtmTime
End With
.Range("B2").Value = Hour(dtmResult)
.Range("B3").Value = Minute(dtmResult)
.Range("B4").Value = Second(dtmResult)
With .Range("B5")
.NumberFormatLocal = "hh.mm.ss"
.Value = dtmResult
End With
End With
Else
MsgBox "時刻が入力されませんでした。最初からやり直してください"
Exit Sub
End If
End If
End Sub
|
|