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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Option Explicit
Sub Prestation()
Dim FL1 As Worksheet
Dim FL2 As Worksheet
Dim Cell As Range, adres As Integer
Dim Plage As Range
Set FL1 = Worksheets("Data Global")
Set FL2 = Worksheets("prestation")
FL1.Columns("A:A").NumberFormat = "0"
FL2.Columns("A:A").NumberFormat = "0"
FL1.Activate
Dim Derlig As Long
Derlig = FL1.Cells(Columns(1).Cells.Count, 1).End(xlUp).Row
Set Plage = FL1.Range(Cells(14, 1), Cells(Derlig, 1))
For Each Cell In Plage
adres = Adresse(FL1, Cell, Cell.Offset(0, 1), Cell.Offset(0, 4), Cell.Offset(0, 5))
If Not adres = Empty And Not adres = 0 Then
'*** A modifier en bouclant sur le tableau des N° de lignes ***
Cell.Offset(0, 9) = FL2.Cells(adres, 7)
'********************************************************
End If
Next
Set FL1 = Nothing
Set Plage = Nothing
End Sub
Function Adresse(FL1 As Worksheet, ParamArray ctrs()) As Integer
Dim DerCol As String, NoCol As Integer, Derlig
Dim Colonnes As Variant, Plage As Range, NoLig As Long
Dim FL2 As Worksheet
Set FL2 = Worksheets("prestation")
'MsgBox ctrs(0) & " " & ctrs(1) & " " & ctrs(2) & " " & ctrs(3) & " "
Colonnes = Array(1, 2, 5, 6)
'Suppression d'un filtre existant éventuel
If FL2.FilterMode = True Then FL2.AutoFilterMode = False
DoEvents
'Dernière colonne de la plage de données
DerCol = Split(FL2.Cells(1, Rows(1).Cells.Count).End(xlToLeft).Address, "$")(1)
'Pose du filtre sur toutes les colonnes de la plage de données
FL2.Columns("A:" & DerCol).AutoFilter
DoEvents
'Filtrage des n colonnes
For NoCol = 0 To UBound(ctrs)
Set Plage = FL2.Columns(Colonnes(NoCol))
Plage.CurrentRegion.AutoFilter _
Colonnes(NoCol), ctrs(NoCol)
Next NoCol
Derlig = FL2.Cells(Columns(1).Cells.Count, 1).End(xlUp).Row
'************* A MODIFIER POUR RENVOYER UN TABLEAU DE No DE LIGNES ************
For NoLig = 2 To Derlig
'ok = Not FL2.Rows(NoLig).EntireRow.Hidden
If Not FL2.Rows(NoLig).EntireRow.Hidden Then
Adresse = NoLig
Exit Function
End If
Next
'******************************************************************************
End Function |
Partager