Ok alors le but de cette macro est de trouver des valeurs dans une feuille "BOM" selon des valeurs definies dans une private sub lorsqu'on modifie des cases.
Puis de remplir la feuille "Items (1)" avec des valeurs trouvees en "BOM" selon des conditions
Sub Find_Rows(ItemNb, ItemRow) 'ItemNb = valeur d'une case enregistree avec une private sub, ItemRow = ligne de cette case
Dim FL1 As Worksheet, FL2 As Worksheet, Cell As Range, NoCol1 As Integer, NoCol2 As Long
Dim DerLig1 As Long, DerLig2 As Long, Plage As Range, Container As Range
Dim First As String, Component As String, Intermediary As String
Dim FirstSecond As String, Inter As Variant
Set FL1 = Worksheets("BOM")
Set FL2 = Worksheets("Container_specification")
NoCol1 = 4
NoCol2 = 2
'Détermine la dernière ligne renseignée des feuilles de calculs
DerLig1 = Split(FL1.UsedRange.Address, "$")(4)
DerLig2 = Split(FL2.UsedRange.Address, "$")(4)
'où FL1.Range(FL1.Cells(1, NoCol1), FL1.Cells(DerLig1, NoCol1)) détermine la plage de cellules à lire
'idem pour container
Set Plage = FL1.Range(FL1.Cells(4, NoCol1), FL1.Cells(DerLig1, NoCol1))
Set Container = FL2.Range(FL2.Cells(3, NoCol2), FL2.Cells(DerLig2, NoCol2))
For Each Cell In Plage
If Cell.Value = ItemNb Then
Component = Cell.Offset(0, 2).Value
First = Mid(Component, 1, 1)
If First = "L" Then
Worksheets("Items (1)").Cells(ItemRow, 11) = Component
ElseIf First = "C" Then
If Worksheets("Items (1)").Cells(ItemRow, 13) = "" Then
Worksheets("Items (1)").Cells(ItemRow, 13) = Component
Else
Worksheets("Items (1)").Cells(ItemRow, 14) = Component
End I
ElseIf First = "I" Then
Intermediary = Component
End If
End If
Next Cell
For Each Cell In Plage
If Cell.Value = Intermediary Then
Component = Cell.Offset(0, 2).Value
First = Mid(Component, 1, 1)
FirstSecond = Mid(Component, 1, 2)
Inter = Application.Intersect(Range(Component), Container)
If (First = "P" And Not Inter Is Nothing) Or FirstSecond = "PF" Then 'MON PROBLEME EST ICI :)
Worksheets("Items (1)").Cells(ItemRow, 10) = Component
ElseIf First = "P" Then
Worksheets("Items (1)").Cells(ItemRow, 13) = Component
End If
End If
Next Cell
Set FL1 = Nothing
Set Plage = Nothing
End Sub
Si besoin je peux aussi joindre mes fichiers
Merci de votre aide en tout cas !