1
我想添加具有這樣一個日期(strDateForm = strDate)和strFunction =「1」的列中的所有小時,但我的功能只需要最後一個列中的數據而不是添加所有相應的數據。 有人可以幫助我。取而代之的添加所有在一個列vba excel的小時爲每個,如果
heureTotale = CSng(srcRow.Range.Cells(1, 13).Value)
Public Sub CalculHeuresTotalChauffeur()
Dim tblPagination As ListObject
Set tblPagination = Worksheets("Pagination").ListObjects.Item ("tblPagination")
Dim heureTotale As Single
Dim sommeTotale As Single
If StrComp(tbxTempsChauffeur, "") = 0 Then tbxTempsChauffeur = "0"
If StrComp(tbxTempsChef, "") = 0 Then tbxTempsChef = "0"
If StrComp(tbxTempsDemenageur, "") = 0 Then tbxTempsDemenageur = "0"
If StrComp(tbxTempsCoordonnateur, "") = 0 Then tbxTempsCoordonnateur = "0"
For Each srcRow In tblPagination.ListRows
strDate = srcRow.Range.Cells(1, 3)
strDateFormulaire = dtpDate.Value
strNoFonction = srcRow.Range.Cells(1, 21)
If strDateFormulaire = strDate And strNoFonction = "1" Then
heureTotale = CSng(srcRow.Range.Cells(1, 13).Value)
End If
Next
sommeTotale = heureTotale + CSng(tbxTempsChauffeur.Value)
tbxHeuresChauffeur.Value = sommeTotale
End Sub
試着讓你的另外一共有發生的循環內,讓你的總時間可以繼續累加,而不是發生一個細胞。 – Cyril