Re : Macro qui plante sur; For Each...
Re, le forum, Efgé,
Merci beaucoup, Efgé, pour ton aide.
J'ai suivi tes recommandations et ça a pointé sur cette macro contenu dans mon fichier :
Option Explicit
Public C As Integer ' position colonne
Public d As Integer ' décalage
Public i As Integer ' indice
Public ic As Integer ' index du combobox
Public K As Integer ' position colonne
Public L As Long ' position ligne
Public p As Integer ' position texte recherché
Public pos As Long ' ligne départ
Public spl As Long ' position index départ
Public t As Integer ' n° zone valeur
Public Sub modif() ' procédure de récupération des données antérieures
With UserForm1 ' identification de l'objet concerné
C = Range("basedenrée").Column ' position de la 1ère colonne denrée
L = .ComboBox1.ListIndex + Range("baseplat").Row + 1 ' ligne du plat
d = 0: t = 1 ' initialisation variables décalage et n° textbox
For K = 2 To 16 ' traitement des 15 denrées
If Sheets("CartePlats").Cells(L, C).Offset(0, d).Value <> "" Then
' la denrée était présente
For i = 0 To .Controls("ComboBox" & K).ListCount
' recherche et position de l'index du combobox
If Sheets("CartePlats").Cells(L, C).Offset(0, d).Value _
= .Controls("ComboBox" & K).List(i) Then
.Controls("ComboBox" & K).ListIndex = i
Exit For
End If
Next i
Else
' la denrée était absente
.Controls("ComboBox" & K).ListIndex = -1
End If
For i = 3 To 6 ' traitement des textbox associées
.Controls("textBox" & t).Value = _
Sheets("CartePlats").Cells(L, C).Offset(0, d + i).Value
t = t + 1
Next i
d = d + 7
Next K
End With
End Sub
Peux-tu me dire...
Bien à toi,
Christian