bonjour a tous
A tester:
Avec 2 macros (test et evenementielle Change)
Sub test()
Set c = ActiveSheet.Cells.Find("JANVIER", LookIn:=xlValues, lookat:=xlWhole)
coldeb = c.Column
'11 parceque 12 mois dans l'année
colfin = coldeb + 11
Set c = ActiveSheet.Cells.Find("FOURNISSEUR", LookIn:=xlValues, lookat:=xlWhole)
ldeb = c.Row + 1
colf = c.Column
Set c = ActiveSheet.Cells.Find("RUPTURE", LookIn:=xlValues, lookat:=xlWhole)
colrup = c.Column
Set c = ActiveSheet.Cells.Find("DELAI LIVRAISON", LookIn:=xlValues, lookat:=xlWhole)
coldel = c.Column
For n = ldeb To Cells(65536, colf).End(xlUp).Row
For m = coldeb To colfin
If Cells(n, coldel) <> "" Then
If Cells(n, m) <> "" And Cells(n, m) < Cells(n, coldel) Then
Cells(n, colrup) = "RUPTURE"
Exit For
Else
Cells(n, colrup) = "EN STOCK"
End If
End If
Next m
Next n
End Sub
Re
une facon de proceder par recherche des mots-clés
Code:Sub test() Set c = ActiveSheet.Cells.Find("JANVIER", LookIn:=xlValues, lookat:=xlWhole) coldeb = c.Column '11 parceque 12 mois dans l'année colfin = coldeb + 11 Set c = ActiveSheet.Cells.Find("FOURNISSEUR", LookIn:=xlValues, lookat:=xlWhole) ldeb = c.Row + 1 colf = c.Column Set c = ActiveSheet.Cells.Find("RUPTURE", LookIn:=xlValues, lookat:=xlWhole) colrup = c.Column Set c = ActiveSheet.Cells.Find("DELAI LIVRAISON", LookIn:=xlValues, lookat:=xlWhole) coldel = c.Column For n = ldeb To Cells(65536, colf).End(xlUp).Row For m = coldeb To colfin If Cells(n, coldel) <> "" Then If Cells(n, m) <> "" And Cells(n, m) < Cells(n, coldel) Then Cells(n, colrup) = "RUPTURE" Exit For Else Cells(n, colrup) = "EN STOCK" End If End If Next m Next n End Sub
Re
Voila adapté a 2 colonnes par mois (ce que ma boule de cristal trop embuée m'avait caché)
Suppose egalement que le tableau commence en colonne A
Re
Exact
il y avait une erreur : j'ajoutais 1 a c.row pour avoir ldeb puis 1 encore a ldeb pour demarrer l'inspection
Toutes mes excuses
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Li As Integer
If Target.Count > 1 Then Exit Sub
Li = Target.Row
If Target.Address = "$I$" & Li Or Target.Address = "$O$" & Li Or Target.Address = "$U$" & Li Then
If Target < Range("C" & Li) Then
Cells(Li, "B") = "RUPTURE"
Else
Cells(Li, "B") = "EN STOCK"
End If
End If
End Sub
Salut,
pierrejean avait répondu avant que je n'ai fini ma macro.
La demande ayant changé, voici peut-être un code correspondant (changement à partir de cellules isolées) :
Code:Private Sub Worksheet_Change(ByVal Target As Range) Dim Li As Integer If Target.Count > 1 Then Exit Sub Li = Target.Row If Target.Address = "$I$" & Li Or Target.Address = "$O$" & Li Or Target.Address = "$U$" & Li Then If Target < Range("C" & Li) Then Cells(Li, "B") = "RUPTURE" Else Cells(Li, "B") = "EN STOCK" End If End If End Sub