this is my first post on the community and i'm hoping for it to be useful for me as well for other members.
I know that this question has been asked many times on this forum, but everyone got a different situation.
I'm trying to create a Macro that would calculate the number of hours from a range of cells. If they match the number i put on my condition then it's good to go, if not i want to display a msgbox or catch the error.
A quick look of the excel template
This is the code of my existing Macro, but i only managed to calculate the first range, i want to add a loop that would calculate the number of hours for every existing column: Which could be variant from 1 day to 31 days depending on the person using the excel template.
The number of projects could vary too "Code OTP" from 1 to 10 projects.
Sub SommeEnVBA_1b()
MaColonne = 2 '(= colonne "B")
MaPremiereLigne = 8
MaDerniereLigne = 1000
Dim i As Integer
MaSomme = 0
For UneLigne = MaPremiereLigne To MaDerniereLigne
MaSomme = MaSomme + Cells(UneLigne, MaColonne).Value
Next UneLigne
If MaSomme = "8,8" Then
MsgBox "Les heures entrées sont correctes : " & MaSomme
Else
MsgBox "Les heures entrées sont incorrectes"
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire