C'était bien ça!
Merci!
Par contre j'ai un autre problème qui est apparu.
Voilà mon code :
Dim contenu As String
Dim Box As Integer
Dim CodeClient As Integer
Range("D4").Select
contenu = ActiveCell.Value
If contenu <> (Range("J2").Value And Range("M2").Value And Range("P2").Value And Range("S2").Value And Range("V2").Value And Range("Y2").Value And Range("AB2").Value And Range("AE2").Value And Range("AH2").Value And Range("AK2").Value And Range("AN2").Value And Range("AQ2").Value And Range("AT2").Value And Range("AW2").Value And Range("AZ2").Value And Range("BC2").Value And Range("BF2").Value And Range("BI2").Value And Range("BL2").Value And Range("BO2").Value And Range("BR2").Value And Range("BU2").Value And Range("BX2").Value And Range("CA2").Value And Range("CD2").Value And Range("CG2").Value And Range("CJ2").Value And Range("CM2").Value And Range("CP2").Value And Range("CS2").Value And Range("CV2").Value And Range("CY2").Value And Range("DB2").Value And Range("DE2").Value And Range("DH2").Value And Range("DK2").Value And Range("DN2").Value And Range("DQ2").Value And Range("DT2").Value And Range("DW2").Value And Range("DZ2").Value And _
Range("EC2").Value And Range("EF2").Value And Range("EI2").Value And Range("EL2").Value And Range("EO2").Value And Range("ER2").Value And Range("EU2").Value And Range("EX2").Value And Range("FA2").Value And Range("FD2").Value And Range("FG2").Value And Range("FJ2").Value And Range("FM2").Value And Range("FP2").Value And Range("FS2").Value And Range("FV2").Value And Range("FY2").Value And Range("GB2").Value And Range("GE2").Value And Range("GH2").Value And Range("GK2").Value And Range("GN2").Value And Range("GQ2").Value And Range("GT2").Value And Range("GW2").Value And Range("GZ2").Value And Range("HC2").Value And Range("HF2").Value And Range("HI2").Value And Range("HL2").Value And Range("HO2").Value And Range("HR2").Value And Range("HU2").Value And Range("HX2").Value And Range("IA2").Value And Range("ID2").Value And Range("IG2").Value And Range("IJ2").Value And Range("IM2").Value And Range("IP2").Value And Range("IS2").Value) Then
Box = MsgBox("Code Client éroné! Veuillez Saisir un code client valide dans la cellule D4")
Else
Range("J2").Select
If contenu = ActiveCell.Value Then
CodeClient = 11
End If
Range("M2").Select
If contenu = ActiveCell.Value Then
CodeClient = 14
End If
...........
.........
............
...........
If contenu = ActiveCell.Value Then
CodeClient = 248
End If
Range("IP2").Select
If contenu = ActiveCell.Value Then
CodeClient = 251
End If
Range("IS2").Select
If contenu = ActiveCell.Value Then
CodeClient = 254
End If
Rows("8:8").Select
Selection.AutoFilter
Selection.AutoFilter Field:=CodeClient, Criteria1:="<>"
Sheets(1).Select
Sheets.Add
ActiveSheet.Name = "Fiche Client"
Sheets("Fiche Client").Move After:=Sheets(2)
Sheets(1).Select
If CodeClient = 11 Then
Columns("J:K").Select
End If
If CodeClient = 14 Then
Columns("M:N").Select
End If
..........
...........
...........
If CodeClient = 248 Then
Columns("IA:IB").Select
End If
If CodeClient = 251 Then
Columns("ID:IE").Select
End If
If CodeClient = 254 Then
Columns("IG:IH").Select
End If
Selection.Copy
Sheets("Fiche Client").Select
Range("E1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets(1).Select
Columns("B:E").Select
Selection.Copy
Sheets("Fiche Client").Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("D
").EntireColumn.AutoFit
Range("G6").Select
ActiveSheet.Buttons.Add(440.25, 39, 60, 24).Select
Selection.OnAction = "SupprimerFicheClient"
ActiveSheet.Shapes("Button 1").Select
Selection.Characters.Text = "Supprimer"
With Selection.Characters(Start:=1, Length:=9).Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End If
Range("D4").Select
End Sub
La boite de message s'affiche bien lorsque l'utilisateur ne saisie pas de code client ou saisie un code éroné, mais elle s'affiche aussi lorsque je saisie un code client valide (cad présent dans les cellules J2, M2....IS2) et la suite de la macro ne s'exécute plus.
Voyez-vous d'où vient le problème?