Bonjour,
je suis débutante en VBA (jai commencé en début de semaine). Je fais une boucle, à l'intérieur de laquelle je fais une trentaine de if imbriqués. Je me retrouve avec une erreur 438, qui a priori n'a pas de solution unique!
Est-ce-que quelqu'un pourrait m'aider svp?
Voici mon code (ouais je sais c'est un peu compliqué et long à lire...):
Sub RechercheCompo()
Dim Cible1 As String
Dim Cible2 As String
Dim Cible3 As String
Dim Cible4 As String
Dim Cible5 As String
Dim Cible6 As String
Dim Cible7 As String
Dim Cible8 As String
Dim Cible9 As String
Dim Cible10 As String
Dim Cible11 As String
Dim Cible12 As String
Dim Cible13 As String
Dim Cible14 As String
Dim Cible15 As String
Dim Cible16 As String
Dim Cible17 As String
Dim Cible18 As String
Dim Cible19 As String
Dim Cible20 As String
Dim Cible21 As String
Dim Cible22 As String
Dim Cible23 As String
Dim Cible24 As String
Dim Cible25 As String
Dim Cible26 As String
Dim Cible27 As String
Dim Cible28 As String
Dim Cible29 As String
Dim Cible30 As String
Dim Cible31 As String
Dim Cible32 As String
Dim Cible33 As String
Cible1 = "acier, fut"
Cible2 = "acrylique"
Cible3 = "alu"
Cible4 = "bronze"
Cible5 = "noir"
Cible6 = " chr "
Cible7 = " cuivre, cupro, cu/ni "
Cible8 = " esther "
Cible9 = " galva "
Cible10 = " glycol "
Cible11 = " diluant, gasoil "
Cible12 = " inox, bague, clavette, écrou, collier, compact, cable, stainless, vis, entretoise, durite, vis, fourreau, manille, profil, outillage, tuyau, union "
Cible13 = " roche "
Cible14 = " laine de verre "
Cible15 = " lait "
Cible16 = " balsa "
Cible17 = " adh "
Cible18 = " nic "
Cible19 = " intergard "
Cible20 = " catalyseur "
Cible21 = " plomb "
Cible22 = "film"
Cible23 = " crestomer, gel, garcette, resine, mastic"
Cible24 = " gravicol, flacon "
Cible25 = " polypro "
Cible26 = " sika, polyur. "
Cible27 = "pvc, taud"
Cible28 = "fil roving, filet, mat, verre, pyrex, vitre "
Cible29 = "plast, silicone, poignee, caout, flex, paulstra "
Cible30 = " styrene "
Cible31 = " caloretanche "
Cible32 = " tissu roving "
Cible33 = " vinylester "
Dim i As Integer
i = 0
Do
i = i + 1
If (InStr(Cible1, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "acier" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible2, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "acrylique" And Sheets("nomenclature" ).cell(i, 7).Value = "1B"
ElseIf (InStr(Cible3, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "aluminium" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible4, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "bronze" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible5, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "elastomère" And Sheets("nomenclature" ).cell(i, 7).Value = "3C"
ElseIf (InStr(Cible6, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "chrome" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible7, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "cupro nickel" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible8, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "esther" And Sheets("nomenclature" ).cell(i, 7).Value = "1J"
ElseIf (InStr(Cible9, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "galva" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible10, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "glycol" And Sheets("nomenclature" ).cell(i, 7).Value = "1F"
ElseIf (InStr(Cible11, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "hydrocarbure" And Sheets("nomenclature" ).cell(i, 7).Value = "2C"
ElseIf (InStr(Cible12, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "inox" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible13, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "laine de roche" And Sheets("nomenclature" ).cell(i, 7).Value = "1J"
ElseIf (InStr(Cible14, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "laine de verre" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible15, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "laiton" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible16, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "matériau de construction" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible17, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "mousse de polyéthylène" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible18, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "nickel" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible19, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "peinture" And Sheets("nomenclature" ).cell(i, 7).Value = "1B"
ElseIf (InStr(Cible20, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "peroxyde de méthyléthylcétone" And Sheets("nomenclature" ).cell(i, 7).Value = "3B"
ElseIf (InStr(Cible21, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "plomb" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible22, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "polyamide" And Sheets("nomenclature" ).cell(i, 7).Value = "3C"
ElseIf (InStr(Cible23, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "polyester" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible24, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "polyester et styrène" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible25, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "polypropylène" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible26, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "polyuréthane" And Sheets("nomenclature" ).cell(i, 7).Value = "1H"
ElseIf (InStr(Cible27, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "PVC" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible28, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "résine de verre" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible29, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "silicone" And Sheets("nomenclature" ).cell(i, 7).Value = "1B"
ElseIf (InStr(Cible30, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "styrène" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible31, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "teflon" And Sheets("nomenclature" ).cell(i, 7).Value = "3C"
ElseIf (InStr(Cible32, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "tissu de verre" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
ElseIf (InStr(Cible33, Sheets("nomenclature" ).cell(i, 3)) <> 0) Then
Sheets("nomenclature" ).cell(i, 6).Value = "vynilesther" And Sheets("nomenclature" ).cell(i, 7).Value = "1C"
End If
Loop Until Sheets("nomenclature" ).cell(i, 3).Value = Null
End Sub
---------------
BénéNC