Re : difficultés à coder sous VBA
bonsoir tout d'abord, merci de m'avoir répondu.
ton aide m'a été precieuse. j'ai cependant modifié le code pour avoir exactement ce que je voulais ca donne ca :
Private Sub Workbook_Open()
Dim derlig As Integer
Dim i As Integer
derlig = Range("g65536").End(xlUp).Row
For i = 2 To derlig
If Len(Cells(i, 9).Value) > 0 Then
Range(Cells(i, 5), Cells(i, 9)).Select
coul_bleu
Else
If Cells(i, 7).Value <= Date Then Cells(i, 7).Interior.Color = RGB(255, 0, 0)
If Cells(i, 7).Value = 0 Then Cells(i, 7).Interior.Color = vbWhite
If Cells(i, 8).Value <= Date Then Cells(i, 8).Interior.Color = RGB(255, 0, 0)
If Cells(i, 8).Value = 0 Then Cells(i, 8).Interior.Color = vbWhite
End If
If Len(Cells(i, 12).Value) > 0 Then
Range(Cells(i, 10), Cells(i, 12)).Select
coul_bleu
Else
If Cells(i, 10).Value <= Date Then Cells(i, 10).Interior.Color = RGB(255, 0, 0)
If Cells(i, 10).Value = 0 Then Cells(i, 10).Interior.Color = vbWhite
If Cells(i, 11).Value <= Date Then Cells(i, 11).Interior.Color = RGB(255, 0, 0)
If Cells(i, 11).Value = 0 Then Cells(i, 11).Interior.Color = vbWhite
End If
If Len(Cells(i, 16).Value) > 0 Then
Range(Cells(i, 13), Cells(i, 16)).Select
coul_bleu
Else
If Cells(i, 13).Value <= Date Then Cells(i, 13).Interior.Color = RGB(255, 0, 0)
If Cells(i, 13).Value = 0 Then Cells(i, 13).Interior.Color = vbWhite
If Cells(i, 14).Value <= Date Then Cells(i, 14).Interior.Color = RGB(255, 0, 0)
If Cells(i, 14).Value = 0 Then Cells(i, 14).Interior.Color = vbWhite
If Cells(i, 15).Value <= Date Then Cells(i, 15).Interior.Color = RGB(255, 0, 0)
If Cells(i, 15).Value = 0 Then Cells(i, 15).Interior.Color = vbWhite
End If
If Len(Cells(i, 19).Value) > 0 Then
Range(Cells(i, 17), Cells(i, 19)).Select
coul_bleu
Else
If Cells(i, 17).Value <= Date Then Cells(i, 17).Interior.Color = RGB(255, 0, 0)
If Cells(i, 17).Value = 0 Then Cells(i, 17).Interior.Color = vbWhite
If Cells(i, 18).Value <= Date Then Cells(i, 18).Interior.Color = RGB(255, 0, 0)
If Cells(i, 18).Value = 0 Then Cells(i, 18).Interior.Color = vbWhite
End If
If Len(Cells(i, 22).Value) > 0 Then
Range(Cells(i, 20), Cells(i, 22)).Select
coul_bleu
Else
If Cells(i, 20).Value <= Date Then Cells(i, 20).Interior.Color = RGB(255, 0, 0)
If Cells(i, 20).Value = 0 Then Cells(i, 20).Interior.Color = vbWhite
If Cells(i, 21).Value <= Date Then Cells(i, 21).Interior.Color = RGB(255, 0, 0)
If Cells(i, 21).Value = 0 Then Cells(i, 21).Interior.Color = vbWhite
End If
Next
End Sub
j'aurais cependant quelques questions:
1) une fois que la macro est lancée et qu'elle a fait le boulot, peut on revenir en arriere sans devoir la supprimer?
2) en fait mon tableau ici est connecté à une autre database(QUERY) il est donc actualisé lorsque la database contient de nouvelle données, cependant celles ci sont classées autrement dans mon tableau et lorsque je lance la macro,
ca devient le bordel.
par exemple, si une ligne s'ajoute apres actualisation, elle n appliquera pas le code correctement au tableau tout sera décalé.
de plus lorsque je lance la macro avec mon curseur dans une cellule , celle ci devient bleue automatiquement.
je sais pas si j'ai été assez clair mais pourriez vous m'aider?