B
brizard
Guest
Bonjour, je voudrai à partir d'une fonction with, end with lancer une deusième fonction with end with, puis revenir dans la première fonction with end with. Le problème est lors du retour dans la première fonction ça plante. Si quelqu'un peux m'aider ça serai sympa.
Mes variables sont déclarées "Public" dans un module.
Sub recherche1()
Worksheets("FRUITS ET LEGUMES").Activate
With Range("A1", "A20")
Set légumes = .Find("TOMATES")
If Not légumes Is Nothing Then
firstAddress = légumes.Address
Do
Worksheets("ESPAGNE").Activate
Range("A1").Select
Call recherche2
Set légumes = .FindNext(légumes)
Loop While Not légumes Is Nothing And légumes.Address <> firstAddress
End If
End With
End Sub
Sub recherche2()
With Range("A1", "A20")
Set barquette = .Find("Barquette 1kg5")
If Not barquette Is Nothing Then
firstAddress = barquette.Address
Do
barquette.Offset(0, 1).Select
Worksheets("FRUITS ET LEGUMES").Activate
Exit With
Set barquette = .FindNext(barquette)
Loop While Not barquette Is Nothing And barquette.Address <> firstAddress
End If
End With
End Sub
Mes variables sont déclarées "Public" dans un module.
Sub recherche1()
Worksheets("FRUITS ET LEGUMES").Activate
With Range("A1", "A20")
Set légumes = .Find("TOMATES")
If Not légumes Is Nothing Then
firstAddress = légumes.Address
Do
Worksheets("ESPAGNE").Activate
Range("A1").Select
Call recherche2
Set légumes = .FindNext(légumes)
Loop While Not légumes Is Nothing And légumes.Address <> firstAddress
End If
End With
End Sub
Sub recherche2()
With Range("A1", "A20")
Set barquette = .Find("Barquette 1kg5")
If Not barquette Is Nothing Then
firstAddress = barquette.Address
Do
barquette.Offset(0, 1).Select
Worksheets("FRUITS ET LEGUMES").Activate
Exit With
Set barquette = .FindNext(barquette)
Loop While Not barquette Is Nothing And barquette.Address <> firstAddress
End If
End With
End Sub