VBA boucle For non fonctionnelle

Bonjour,

Je sais pas ce qu'il se passe j'ai un gros problème, j'ai deux boucles For imbriquées l'une dans l'autre mais il n'incrémente jamais la boucle en j.

Mystère je comprends pas. Pour l'instant je vous joins pas les fichiers mais pouvez me dire si vous voyez un problème au niveau de ces boucles ?

D'avance merci.

Public Sub verif_DWR()

Dim derligPin_vr As Integer, derligPinC_mpa As Integer, derligPinA_mpa As Integer
Dim i As Long, j As Long, index As Long
Dim idx_cabinet_vr As Integer, idx_moduleID_vr As Integer, idx_pin_vr As Integer, idx_pinC_mpa As Integer, idx_pinA_mpa As Integer
Dim TEST As Boolean, TEST2 As Boolean
Dim Results As Worksheet, Pin As Worksheets, Feuil1 As Worksheets
Dim wb_vr As Workbook, wb_mpa As Workbook, tw As Workbook

Application.ScreenUpdating = False
UserForm1.Height = 352.2
UserForm1.Label5.Caption = "Vérification de la DWR"

On Error Resume Next
Set wb_vr = Workbooks.Open(UserForm1.TextBox1.Value)
Set wb_mpa = Workbooks.Open(UserForm1.TextBox2.Value)
Set tw = ThisWorkbook

idx_cabinet_vr = searchcolumn(wb_vr, "Results", "Cabinet")
idx_moduleID_vr = searchcolumn(wb_vr, "Results", "Module ID")
idx_pin_vr = searchcolumn(wb_vr, "Results", "PIN")
idx_pinC_mpa = searchcolumn(wb_mpa, "Pin", "Pin Connector")
idx_pinA_mpa = searchcolumn(wb_mpa, "Pin", "Pin address")

derligPin_vr = wb_vr.Worksheets("Results").Cells(Rows.Count, idx_pin_vr).End(xlUp).Row
derligPinC_mpa = wb_mpa.Worksheets("Pin").Cells(Rows.Count, idx_pinC_mpa).End(xlUp).Row
derligPinA_mpa = wb_mpa.Worksheets("Pin").Cells(Rows.Count, idx_pinA_mpa).End(xlUp).Row

index = 2

wb_mpa.Activate
wb_vr.Activate

For i = 2 To derligPin_vr
    For j = 1 To derligPin_mpa
        If wb_vr.Worksheets("Results").Cells(i, idx_pin_vr) <> "" Then
        TEST = True
            If wb_vr.Worksheets("Results").Cells(i, idx_pin_vr) = wb_mpa.Worksheets("Pin").Cells(j, idx_pinC_mpa) & wb_mpa.Worksheets("Pin").Cells(j, idx_pinA_mpa) Then
            TEST2 = True
            tw.Worksheets("Feuil1").Cells(index, 1).Value = wb_vr.Worksheets("Results").Cells(i, idx_pin_vr).Value
            index = index + 1
            End If
        Else
        MsgBox ("NOK")
        End If
    Next j
Next i

Application.ScreenUpdating = True
UserForm1.Height = 367.2
Unload UserForm1

End Sub

Bonjour,

tu l'as fait en pas à pas avec F8 pour affirmer que la 2nde boucle ne s'exécute pas ?

Si non, c'est comme qu'il faut faire si tu veux voir à quel endroit ça pèche.

eric

Bonjour eriiic,

Merci pour ta réponse, oui j'ai mis un arrêt sur next j, il y a uniquement next i qui s'incrémente mais la boucle en j il s'en fou

Je comprends pas pourtant j'en ai fais pas mal des boucles for jamais eu ce problème. Pour information, tous les idx et derlig ont bien une valeur.

Serait il possible que excel soit beugé ?

bonjour

a revoir For j = 1 To derligPin_mpa

derligPin_mpa = 0

A+

Maurice

Bonjour archer,

J'ai cherché pendant 2h pour une fichue lettre oubliée. Merci beaucoup. Je commençais à déprimer la lol

Rechercher des sujets similaires à "vba boucle fonctionnelle"