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 test()
Dim FL1 As Worksheet
Dim FL2 As Worksheet
Dim Plage1 As Variant, NbLig As Integer, adres1 As String
Dim Plage2 As Range, adres2 As String, nbcol As Integer
Dim c As Range, Result As Range
adres1 = "A2:D5" 'Plage cherchée
adres2 = "A10:D74" 'Plage à laquelle appliquer la recherche
Set FL1 = Workbooks("Classeur4").Worksheets("feuil1")
Set FL2 = Workbooks("Classeur5").Worksheets("feuil1")
'Nb de colonnes et de lignes utiles pour l'offset
nbcol = FL2.Range(Split(adres2, ":")(1)).Column - Range(Split(adres2, ":")(0)).Column
NbLig = FL1.Range(adres1).Rows.Count - 1
Plage1 = FL1.Range(adres1).Value 'plage cherchée
Set Plage2 = Range(adres2) 'Instance de la plage où effectuer la recherche
With Plage2
Set c = .Find(Plage1)
If Not c Is Nothing Then
Set Result = FL2.Range(c.Address, c.Offset(NbLig - 1, nbcol))
'ou ********************************************
Dim trouve As String
trouve = FL2.Range(c.Address, c.Offset(NbLig, nbcol)).Address
MsgBox trouve
' **********************************************
End If
'ou **********************************************
Dim ok As Boolean
ok = Not c Is Nothing
'*************************************************
End With
Set c = Nothing
Set Plage2 = Nothing
Set FL1 = Nothing
Set FL2 = Nothing
End Sub |
Partager