3GB, je n'ai rein changé sur le fichier je peux même en faire un nouveau pour essayer, voici ton code avec un trace sur la colonne 4 du V6 dans le env.conf
Si je tape PACAC une fois, il me copie les lignes hors prod, si je le retape une 2eme fois il me mets des lignes prod mais mélanger avec du hors prod !!!
Sub EnvoiConf(Cible As Range)
Dim shV6 As Worksheet, shEnv As Worksheet, shVP As Worksheet
Dim cell As Range
Dim Lcible As Long, NvL As Long
Dim txts$
Set shV6 = Worksheets("V6.x")
Set shVP = Sheets("Param")
txts = Join(Array("DIJON DOP2R", "DEV Dijon", "CSH DIJON", "CNE DOP2R"), "")
Lcible = Cible.Row 'ligne en cours
If Worksheets(Worksheets.Count).Name = "env.conf" Then 'si env.conf existe
Set shEnv = Sheets("env.conf") 'shEnv = env.conf 'affectation de shEnv
Else
Set shEnv = Sheets.Add(After:=Worksheets(Worksheets.Count)) 'sinon, Creation d'un nouvel onglet
With shEnv
.Name = "env.conf" 'on le renomme env.conf
.ListObjects.Add(Source:=Range("A1:F2"), XlListObjectHasHeaders:=xlYes).Name = "CONF" 'crŽe tableau structurŽ nommŽ CONF
.Range("CONF[#Headers]").Value = Array("", "", "", "", "", "") 'nomme les colonnes
.Range("CONF[#Headers]").HorizontalAlignment = xlHAlignCenter 'centre les entetes
Worksheets("Param").Range("A1:F11").Copy .Range("CONF").Cells(1) 'envoie les valeurs de Paramen dŽbut de tableau
End With
End If
With shEnv.Range("CONF") 'sur env.conf
NvL = .Rows.Count + 1 'NvL = nb lignes tableau env.conf + 1 (plus besoin condition car CONF non vide)
If InStr(txts, Cells(Lcible, 4).Value) > 0 Then 'si ligne cliquŽe correspond au critre
For Each cell In Range("CSM[CSM]") 'parcourt chaque cellule de la col 4 du tableau v6
If Not cell.Value = "" And InStr(txts, cell.Value) > 0 Then 'qd correspondance avec critre trouvŽe
Lcible = cell.Row 'Lcible prend valeur de la ligne en cours
.Cells(NvL, 1).Value = "ENV;"
.Cells(NvL, 2).Value = " ;"
.Cells(NvL, 3).Value = "XDUAS_COMPANY;"
.Cells(NvL, 4).Value = shV6.Cells(Lcible, 2).Value & ";" 'en col 4 env.conf : recoit valeur colonne 2
.Cells(NvL, 5).Value = "XDUAS_PORT;"
.Cells(NvL, 6).Value = Left(shV6.Cells(Lcible, 3), 6)
.Cells(NvL, 7).Value = shV6.Cells(Lcible, 4)
NvL = NvL + 1 'incrŽmentation de NvL pour suivant
End If
Next cell
Else 'sinon, critre absent (idem mais quand critre absent)
For Each cell In Range("CSM[CSM]")
If Not cell.Value = "" And InStr(txts, cell.Value) = 0 Then
Lcible = cell.Row
.Cells(NvL, 1).Value = "ENV;"
.Cells(NvL, 2).Value = " ;"
.Cells(NvL, 3).Value = "XDUAS_COMPANY;"
.Cells(NvL, 4).Value = shV6.Cells(Lcible, 2).Value & ";"
.Cells(NvL, 5).Value = "XDUAS_PORT;"
.Cells(NvL, 6).Value = Left(shV6.Cells(Lcible, 3), 5)
.Cells(NvL, 7).Value = shV6.Cells(Lcible, 4)
NvL = NvL + 1
End If
Next cell
End If
End With
With shEnv.Range("CONF")
.Columns.EntireColumn.AutoFit 'ajuste largeur colonnes
.HorizontalAlignment = xlHAlignCenter 'centre les valeurs
End With
End Sub