Bonjour,
Il faut ajouter une nouvelle condition dans la ligne
If (InStr(VarFile(J), VarExcel(K)) > 0 And Not IsEmpty(VarExcel(K))) Or (VarFile(J) = Mid(VarExcel(K), 1, Len(VarFile(J))) And Not IsEmpty(VarFile(J))) Then
Le code devient
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Sub ComparerVarExcel()
Dim Cpt As Long
Dim J As Long
Dim K As Long
Dim PresenceDoublon As Boolean
Dim CompteurCh1 As Long
ReDim Ch1(0)
Call ChargementVarfile
Call ChargerVarExcel
Cpt = 0
For J = 0 To UBound(VarFile)
For K = 0 To UBound(VarExcel)
If (InStr(VarFile(J), VarExcel(K)) > 0 And Not IsEmpty(VarExcel(K))) Or (VarFile(J) = Mid(VarExcel(K), 1, Len(VarFile(J))) And Not IsEmpty(VarFile(J))) Then
MsgBox ("Valeur Varfile : " & VarFile(J) & Chr(10) & "Valeur VarExcel : " & VarExcel(K) & Chr(10) & " Valeur Instr : " & InStr(VarFile(J), VarExcel(K)))
PresenceDoublon = False
For CompteurCh1 = LBound(Ch1) To UBound(Ch1)
If Ch1(CompteurCh1) = VarFile(J) Then PresenceDoublon = True
Next CompteurCh1
If PresenceDoublon = False Then
Select Case Cpt
Case 0
Ch1(Cpt) = VarFile(J)
MsgBox ("Ch1 : " & Ch1(Cpt))
Cpt = Cpt + 1
Case Else
ReDim Preserve Ch1(Cpt)
Ch1(Cpt) = VarFile(J)
MsgBox ("Ch1 : " & Ch1(Cpt))
Cpt = Cpt + 1
' Debug.Print Ch1(Cpt)
End Select
End If
End If
Next K
Next J
End Sub |
Cordialement.
Partager