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
|
Sub Macro3()
Dim Continuer As Boolean
Dim ShMacro3 As Worksheet
Dim ShPrix As Worksheet
Dim DerniereLignePrix As Long
Dim LigneDeTitrePrix As Long
Dim ListeDesProduits As Range
Set ShPrix = Sheets("prix")
With ShPrix
LigneDeTitrePrix = 1
DerniereLignePrix = .Cells(.Rows.Count, 1).End(xlUp).Row
If DerniereLignePrix > LigneDeTitrePrix Then
Set ListeDesProduits = .Range(.Cells(LigneDeTitrePrix + 1, 1), .Cells(DerniereLignePrix, 1))
Continuer = False
For Each ShMacro3 In Sheets
If ShMacro3.Name = "Macro3" Then Continuer = True
Next ShMacro3
If Continuer = True Then
Sheets("Macro3").Cells.Clear
Set ShMacro3 = Sheets("Macro3")
Else
Set ShMacro3 = Sheets.Add(After:=ShPrix)
ShMacro3.Name = "Macro3"
End If
CopierLesProduitsSuperieursA100 ShMacro3, ListeDesProduits, 100#
Set ShMacro3 = Nothing
Set ListeDesProduits = Nothing
End If
End With
End Sub
Sub CopierLesProduitsSuperieursA100(ByVal FeuilleCible As Worksheet, ByVal AireProduits As Range, ByVal ValeurSeuil As Single)
Dim Cellule As Range
Dim LigneEnCours As Long
With FeuilleCible
.Range(.Cells(1, 1), .Cells(1, 2)) = Array("Produits", "Prix")
LigneEnCours = 2
For Each Cellule In AireProduits
If Cellule.Offset(0, 1) >= ValeurSeuil Then
.Cells(LigneEnCours, 1) = Cellule
.Cells(LigneEnCours, 2) = Cellule.Offset(0, 1)
LigneEnCours = LigneEnCours + 1
End If
Next Cellule
End With
End Sub |
Partager