1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Function SommeEntreSlashEtAntiSlash(AireEtudiee As Range, CaracteresDebut As String, CaractereFin As String)
' © Eric KERGRESSE EIRL
Dim Cellule As Range
Dim I As Integer
Dim PositionASlash As Integer
Dim PositionAntiSlash As Integer
SommeEntreSlashEtAntiSlash = 0
For Each Cellule In AireEtudiee
PositionASlash = 0
' Contrôle présence A/
For I = 1 To Len(Cellule)
If Mid(Cellule, I, 2) = CaracteresDebut Then PositionASlash = I
Next I
' Contrôle présence \
PositionAntiSlash = 0
If PositionASlash > 0 Then
If PositionASlash + 2 <= Len(Cellule) Then
For I = PositionASlash + 2 To Len(Cellule)
If Mid(Cellule, I, 1) = CaractereFin Then
PositionAntiSlash = I
Exit For
End If
Next I
End If
End If
Select Case PositionAntiSlash
Case 0
SommeEntreSlashEtAntiSlash = SommeEntreSlashEtAntiSlash + Val(Mid(Cellule, PositionASlash + 2))
' MsgBox (Val(Mid(Cellule, PositionASlash + 2)))
Case Else
SommeEntreSlashEtAntiSlash = SommeEntreSlashEtAntiSlash + Val(Mid(Cellule, PositionASlash + 2, PositionAntiSlash - (PositionASlash + 2)))
' MsgBox (Val(Mid(Cellule, PositionASlash + 2, PositionAntiSlash - (PositionASlash + 2))))
End Select
Next Cellule
End Function |
Partager