Modifier doublon sous condition
Résolu
Leghe59
Messages postés
34
Date d'inscription
Statut
Membre
Dernière intervention
-
Leghe59 Messages postés 34 Date d'inscription Statut Membre Dernière intervention -
Leghe59 Messages postés 34 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je bloque sur la macro suivante :
- Classeur :
ISBN DISPO FOURNISSEUR
3281553413593 non dispo LIBRISOFT
3282118102310 dispo CRAENEN
3282118102310 non dispo LIBRISOFT
- Objectif :
SI ISBN = doublon
SI FOURNISSEUR = "CRAENEN" ET DISPO = "dispo"
ALORS FOURNISSEUR "LIBRISOFT" DISPO = "DISPONIBLE"
Donc :
ISBN DISPO FOURNISSEUR
3281553413593 non dispo LIBRISOFT
3282118102310 dispo CRAENEN
3282118102310 DISPONIBLE LIBRISOFT
Ma macro :
Où est mon erreur ?
Merci à tou(te)s !
Je bloque sur la macro suivante :
- Classeur :
ISBN DISPO FOURNISSEUR
3281553413593 non dispo LIBRISOFT
3282118102310 dispo CRAENEN
3282118102310 non dispo LIBRISOFT
- Objectif :
SI ISBN = doublon
SI FOURNISSEUR = "CRAENEN" ET DISPO = "dispo"
ALORS FOURNISSEUR "LIBRISOFT" DISPO = "DISPONIBLE"
Donc :
ISBN DISPO FOURNISSEUR
3281553413593 non dispo LIBRISOFT
3282118102310 dispo CRAENEN
3282118102310 DISPONIBLE LIBRISOFT
Ma macro :
Sub nouveautes()
Dim ISBN As Range
Dim dl As Long
Dim x As Long
Dim y As Long
Dim Fournisseur As Range
Dim Dispo As Range
Set ISBN = Range("A2:A" & Range("A2").End(xlDown).Row)
Set Fournisseur = Range("C2:C" & Range("C2").End(xlDown).Row)
Set Dispo = Range("B2:B" & Range("B2").End(xlDown).Row)
ISBN.CurrentRegion.Sort Key1:=ISBN, Order1:=xlAscending, Header:=xlYes
dl = Cells(Application.Rows.Count, 1).End(xlUp).Row
For x = dl to 2 step - 1
y = x - 1
If Application.WorksheetFunction.CountIf(Range("A2:A" & dl), Cells(x, 1)) > 1 Then
If UCase(Dispo.Cells(x).Value) Like "dispo" Then Dispo.Cells(y).Value = "DISPONIBLE"
End If
Next x
End Sub
Où est mon erreur ?
Merci à tou(te)s !
A voir également:
- Modifier doublon sous condition
- Modifier dns - Guide
- Modifier liste déroulante excel - Guide
- Excel cellule couleur si condition texte - Guide
- Modifier story facebook - Guide
- Modifier extension fichier - Guide
4 réponses
yg_be
Messages postés
23541
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 584
bonjour, quel est le symptôme: message d'erreur, résultat inattendu, ?
yg_be
Messages postés
23541
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 584
une erreur simple:
serait mieux ainsi:
une autre erreur:
au lieu de faire
UCase(Dispo.Cells(x).Value) Like "dispo"
serait mieux ainsi:
UCase(Dispo.Cells(x).Value) = "DISPO"
une autre erreur:
au lieu de faire
dispo.Cells(x).Value, ce serait plus correct de faire
Cells(x,2).Value
cela nous conduit à ceci:
tu vas maintenant pouvoir commencer à corriger les problèmes de logique.
Option Explicit Sub nouveautes() Dim ISBN As Range Dim dl As Long Dim x As Long Set ISBN = Range("A2:A" & Range("A2").End(xlDown).Row) ISBN.CurrentRegion.Sort Key1:=ISBN, Order1:=xlAscending, Header:=xlYes dl = Cells(Application.Rows.count, 1).End(xlUp).Row For x = dl To 2 Step -1 If Application.WorksheetFunction.CountIf(ISBN, Cells(x, 1)) > 1 Then If UCase(Cells(x, 2).Value) = "DISPO" Then Cells(x - 1, 2).Value = "DISPONIBLE" End If End If Next x End Sub
tu vas maintenant pouvoir commencer à corriger les problèmes de logique.
Merci pour tes précisions.
Cela dit, cela ne fonctionne toujours pas...
Cela dit, cela ne fonctionne toujours pas...