amélioration d'une macro

bpol

XLDnaute Impliqué
Bonjour,

après avoir travaillé avec le tableau on me eemande une petite amélioration d'une macro.

Code:
Dim target As Range
Dim dc1 As Long

Set target = Range("b4") 
With Sheets("histo")
dc1 = .Cells(target.Offset(0, -1) + 3, Rows(target.Offset(0, -1) + 3).Cells.Count).End(xlToLeft).Column + 1
.Cells(target.Offset(0, -1) + 3, dc1) = Format(Now, "dd.m.yyyy")
End With
[B]With Sheets("compte")
.Cells(target.Offset(0, -1) + 3, 3) = "1"[/B]
End With


il faudrait que la 2e partie de la macro ne fonctionne pas si une cellule dans une autre feuille est égale à X

comment fait on cela?

Merci
Bpol
 

Papou-net

XLDnaute Barbatruc
Re : amélioration d'une macro

Bonjour,

après avoir travaillé avec le tableau on me eemande une petite amélioration d'une macro.

Code:
Dim target As Range
Dim dc1 As Long

Set target = Range("b4") 
With Sheets("histo")
dc1 = .Cells(target.Offset(0, -1) + 3, Rows(target.Offset(0, -1) + 3).Cells.Count).End(xlToLeft).Column + 1
.Cells(target.Offset(0, -1) + 3, dc1) = Format(Now, "dd.m.yyyy")
End With
[B]With Sheets("compte")
.Cells(target.Offset(0, -1) + 3, 3) = "1"[/B]
End With

il faudrait que la 2e partie de la macro ne fonctionne pas si une cellule dans une autre feuille est égale à X

comment fait on cela?

Merci
Bpol

Bonjour bpol,

Si j'ai bien compris, tu peux essayer ainsi :

Code:
If Not sheets("Feuil?").Range("??") = "X"  Then .Cells(target.Offset(0, -1) + 3, 3) = "1"[/B]

Bien sûr, tu remplaces les ? par tes références exactes.

Espérant avoir répondu.

Cordialement.
 

Statistiques des forums

Discussions
312 496
Messages
2 088 974
Membres
103 995
dernier inscrit
Flodk