Problema con calcolo date hhmmss
Hai un problema con Excel? 
Problema con calcolo date hh.mm.ss
di Roccia (utente non iscritto) data: 10/09/2014 15:23:41
Ciao,
ho un problema con un calcolo dei minuti
ho evidenziato la riga che mi da problemi, non mi restituisce la differenza in hh.mm.ss
Roccia
Public Sub mMinuti() ' REGISTRA NUMERO E TEMPO
Dim sh1 As Worksheet
Dim sh3 As Worksheet
Dim lng As Long
Dim lCol As Long
Dim lRiga As Long
Set sh1 = ThisWorkbook.Worksheets("Iscrizioni")
Set sh3 = ThisWorkbook.Worksheets("Conta Giri")
Application.ScreenUpdating = False
With sh1
For lng = 4 To 49
If .Cells(lng, 2).Value = sh3.Range("C6").Value Then
lCol = .Cells(lng, .Columns.Count).End(xlToLeft).Column + 1
.Cells(lng, lCol).Value = Format(sh3.Range("C3"), "hh.mm.ss")
.Cells(lng + 50, lCol).Value = Format(sh3.Range("C3") - .Cells(lng, lCol - 1), "hh.mm.ss")
Exit For
End If
Next lng
End With
With sh3
lRiga = .Range("C" & .Rows.Count).End(xlUp).Row + 1
.Range("C" & lRiga).Value = .Range("C6").Value
.Range("D" & lRiga).Value = Format(.Range("C3"), "hh.mm.ss")
.Range("C6").Value = ""
End With
Application.ScreenUpdating = True
Set sh1 = Nothing
Set sh3 = Nothing
End Sub |
di Luca73 data: 10/09/2014 16:34:52
Così su due piedi provando la tua formula mi sembra corretta. POtrebbe darti errore se una delle date è scritta come testo e non come numero. Nel caso puoi usare la conversione con la funzione VBA CDate().
Ciao
Luca
Vuoi Approfondire?