@Masdad Yang pertama, pastikan data yang ada di A1 benar-benar format tanggal/Date dan di B1 juga formatnya Time.
Untuk kode vbanya:
variabel shp jangan pakai tipe Double karena bukan angka, karena di sel C1 adalah teks maka gunakan tipe data string.
Dim shp As String
Untuk jamprognya juga di buat string saja, untuk format Date dan Timenya nanti dibagian akhir saja pakai CDateDim jamprog As String
Kode selengkapnya:
Sub updateInput()
Dim shp As String
Dim jamprog As String
Let shp = Range("C1").Value
If shp = "M" Then
jamprog = Range("A1").Value + 1 & " " & Format(Range("B1").Value, "hh:mm")
Else
jamprog = Range("A1").Value & " " & Format(Range("B1").Value, "hh:mm")
End If
Range("d1").Value = CDate(jamprog)
End Sub
[attachment:5fd6c485a6cbe]
Terima kasih, sudah berfungsi @Masdad . Dan sekalian saya mau minta koreksi utk coding update data yg telah di edit. codingnya tidak berjalan, padahal acuannya sama dg coding yg saya pakai di userform lainnya. berikut untuk codingnya.
Private Sub Update3_Click()
On Error Resume Next
Dim barisakhir2
Dim X2 As String
Set ws = Worksheets("INPUT")
ws.Activate
barisakhir2 = ws.Range("A" & Rows.Count).End(xlUp).Row
X2 = Tgl_prog.Value
For BARIS5 = 1 To barisakhir2
If Cells(BARIS5, 2).Value = X2 Then
ws.Cells(BARIS5, 1).Value = Me.sn_unit.Value
ws.Cells(BARIS5, 2).Value = Me.Tgl_prog.Value
ws.Cells(BARIS5, 3).Value = Me.lok_proy.Value
ws.Cells(BARIS5, 4).Value = Me.id_K.Value
ws.Cells(BARIS5, 5).Value = Me.id_P.Value
ws.Cells(BARIS5, 6).Value = Me.id_U.Value
ws.Cells(BARIS5, 7).Value = Me.nik.Value
ws.Cells(BARIS5, 8).Value = Me.namaK.Value
ws.Cells(BARIS5, 9).Value = Me.cabin.Value
ws.Cells(BARIS5, 10).Value = Me.shift.Value
ws.Cells(BARIS5, 11).Value = Me.hm_a.Value
ws.Cells(BARIS5, 12).Value = Me.hm_b.Value
ws.Cells(BARIS5, 12).Value = Me.ttl_hm.Value
ws.Cells(BARIS5, 14).Value = Me.jam_a.Value
ws.Cells(BARIS5, 15).Value = Me.jam_b.Value
ws.Cells(BARIS5, 16).Value = Me.istrht.Value
ws.Cells(BARIS5, 17).Value = Me.ttl_jam.Value
ws.Cells(BARIS5, 18).Value = Me.jtd.Value
ws.Cells(BARIS5, 19).Value = Me.unt_muat.Value
ws.Cells(BARIS5, 20).Value = Me.bucket.Value
ws.Cells(BARIS5, 21).Value = Me.stbq.Value
ws.Cells(BARIS5, 22).Value = Me.muat.Value
ws.Cells(BARIS5, 23).Value = Me.jarak.Value
ws.Cells(BARIS5, 24).Value = Me.wb1.Value
ws.Cells(BARIS5, 25).Value = Me.wb2.Value
ws.Cells(BARIS5, 26).Value = Me.wb3.Value
ws.Cells(BARIS5, 27).Value = Me.wb5.Value
ws.Cells(BARIS5, 28).Value = Me.wb6.Value
ws.Cells(BARIS5, 29).Value = Me.wb4.Value
ws.Cells(BARIS5, 30).Value = Me.wb7.Value
ws.Cells(BARIS5, 31).Value = Me.minyak.Value
ws.Cells(BARIS5, 32).Value = Me.ritase.Value
ws.Cells(BARIS5, 32).Value = Me.jen_pek.Value
ws.Cells(BARIS5, 34).Value = Me.lok_muat.Value
ws.Cells(BARIS5, 35).Value = Me.lok_dumping.Value
ws.Cells(BARIS5, 36).Value = Me.des_pek.Value
ws.Cells(BARIS5, 37).Value = Me.keterangan.Value
ws.Cells(BARIS5, 38).Value = Me.Tgl_Inpt.Value
End If
Next BARIS5
Me.lok_proy.SetFocus
Me.sn_unit.Value = ""
Me.Tgl_prog.Value = ""
Me.lok_proy.Value = ""
Me.id_K.Value = ""
Me.id_P.Value = ""
Me.id_U.Value = ""
Me.nik.Value = ""
Me.namaK.Value = ""
Me.cabin.Value = ""
Me.shift.Value = ""
Me.hm_a.Value = ""
Me.hm_b.Value = ""
Me.ttl_hm.Value = ""
Me.jam_a.Value = ""
Me.jam_b.Value = ""
Me.istrht.Value = ""
Me.ttl_jam.Value = ""
Me.jtd.Value = ""
Me.unt_muat.Value = ""
Me.bucket.Value = ""
Me.stbq.Value = ""
Me.muat.Value = ""
Me.jarak.Value = ""
Me.wb1.Value = ""
Me.wb2.Value = ""
Me.wb3.Value = ""
Me.wb5.Value = ""
Me.wb6.Value = ""
Me.wb4.Value = ""
Me.wb7.Value = ""
Me.minyak.Value = ""
Me.ritase.Value = ""
Me.jen_pek.Value = ""
Me.lok_muat.Value = ""
Me.lok_dumping.Value = ""
Me.des_pek.Value = ""
Me.keterangan.Value = ""
Me.Tgl_Inpt.Value = ""
Call MsgBox("Data Telah Update", vbInformation, "Update Data")
End Sub