1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub SelectionnerLignes1(Feuille As Worksheet, ValA As Variant, ValB As Variant)
Dim Cellule As Range, Plage As Range
Dim i As Long
For Each Cellule In Feuille.Range("B5:b" & Feuille.Range("b" & Feuille.Rows.Count).End(xlUp).Row)
If Not IsEmpty(ValB) Then
If Cellule = ValA And Cellule(1, 2) = ValB Then
If Plage Is Nothing Then Set Plage = Union(Cellule, Cellule(1, 2), Cellule(1, 3), Cellule(1, 4), Cellule(1, 5)) Else Set Plage = Union(Plage, Cellule, Cellule(1, 2), Cellule(1, 3), Cellule(1, 4), Cellule(1, 5))
End If
Else
If Cellule = ValA Then
If Plage Is Nothing Then Set Plage = Union(Cellule, Cellule(1, 2), Cellule(1, 3), Cellule(1, 4), Cellule(1, 5)) Else Set Plage = Union(Plage, Cellule, Cellule(1, 2), Cellule(1, 3), Cellule(1, 4), Cellule(1, 5))
End If
End If
Next Cellule
Feuille.Select
If Not Plage Is Nothing Then Plage.Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("BOARDMASTER").Range(Plage), PlotBy:=xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="BOARDMASTER"
End Sub |
Partager