Excel VBA IF with 2 conditions
danielc0 Posted messages 2187 Registration date Status Member Last intervention -
Hello,
beginner in VBA, I am looking, in a macro, to apply a promotion if 2 conditions are met:
In column B the product "status", in column L the supplier:
If (OExport.Range("B" & li).Value = "Arrêt de commercialisation" And OExport.Range("L" & li).Value <> "DEPOT -*") Or OExport.Range("B" & li).Value = "Changement de distributeur" Then
So if the product status is "Arrêt de commercialisation" AND the supplier name does not start with "DEPOT -", or the product status is "Changement de distributeur" Then...
But the first part does not work, the product goes on promo even if Value <> "DEPOT -*".
Where did I go wrong?
Thank you!
2 answers
-
Hello,
With the partial file it would be more profitable..
Put it on SwissTransfer - Secure and free sending of large files
Regards.
Le Pingou -
lifin = OExport.Range("A" & Rows.Count).End(xlUp).Row For li = lifin To 2 Step -1 If (OExport.Range("B" & li).Value = "Arrêt de commercialisation" And OExport.Range("L" & li).Value <> "DEPOT -*") Or OExport.Range("B" & li).Value = "Changement de distributeur" Then Rows(li & ":" & li).Select Application.CutCopyMode = False Selection.Copy Selection.Insert Shift:=xlDown Range("A" & li + 1) = Range("B" & li + 1) & "-O" Range("E" & li + 1) = "1" Range("J" & li + 1) = "Déstockage ! Jamais ouvert - Envoi le jour-même depuis Lille - France" Range("R" & li + 1) = "" End If Next li lifin2 = OVente.Range("A" & Rows.Count).End(xlUp).Row For li = lifin2 To 2 Step -1 If OVente.Range("A" & li).Value Like "*-O" Then Range("D" & li) = (Range("D" & li - 1) / 2) End If