Problème de réalisation Macro EXCEL
Bonjour,
Je vous expose mon problème :
Je cherche à faire un macro excel permettant d'incrémenter une date "X" d'une certaine période "Y" en fonction de la date de l'ouverture du fichier. Mon programme : ==> Avec la C(6,6) la date X; C(1,5) la date " =AUJOURD'HUI "; C(5,4) la période "Y"
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Sub Rempalcer()
If Cells(6, 6) < Cells(1, 5) Then
Cells(5, 5).Value = Cells(5, 5).Value
End If
If Cells(5, 5) = Cells(1, 5) Then
Cells(5, 5).Value = Cells(5, 5).Value
End If
If Cells(5, 5) > Cells(1, 5) Then
Cells(5, 5).Value = Cells(5, 5).Value + Cells(5, 4).Value
End If
End Sub |
Je n'ai toujours pas résolu mon problème :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Dim J, M, A As String
J = Day(CDate(Cells(6, 6).Value))
M = Month(CDate(Cells(6, 6).Value))
A = Year(CDate(Cells(6, 6).Value))
Select Case DateDiff("m", CDate(Cells(6, 6).Value),Date)
Case Is < 0
MsgBox "<0"
Case Is > 0
If M + 6 > 12 Then
M = M + 6 - 12
A = A + 1
Else
M = M + 6
End If
Cells(6, 6).Value = CDate(J & "/" & M & "/" & A)
Case 0
MsgBox "=0"
Case Else
MsgBox "???"
End Select |