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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| Private Sub RempliList(lstbox As Object, ByRef rng As Variant)
Dim j As Byte
With lstbox
.AddItem rng.Cells(1, 1).Value
For j = 1 To 2
.List(.ListCount - 1, j) = rng(1, j + 1)
Next j
End With
End Sub
Private Sub Chart_PL_Analysis(ListBox As Object, CharTNamePLA As Variant, ChartTypePLA As Variant, ChartTitlePLA As String, Plage1 As Range, Optional Etiquette1 As Variant, Optional Etiquette2 As Variant, Optional Etiquette3 As Variant, Optional Etiquette4 As Variant, Optional Etiquette5 As Variant, Optional Plage2 As Variant, Optional Plage3 As Variant, Optional Plage4 As Variant, Optional Plage5 As Variant)
Dim Plage As Range
Dim Mon_Graphique As Shape
Dim Ma_Feuille As Worksheet
On Error Resume Next
ListBox.ColumnCount = 3
ListBox.ColumnWidths = "70;70;70"
ListBox.Clear
Set Plage = Plage1
RempliList ListBox, Plage1
'----------------------------------------
If Not IsMissing(Plage2) Then
Set Plage = Union(Plage, Plage2)
RempliList ListBox, Plage2
End If
'----------------------------------------
If Not IsMissing(Plage3) Then
Set Plage = Union(Plage, Plage3)
RempliList ListBox, Plage3
End If
'----------------------------------------
If Not IsMissing(Plage4) Then
Set Plage = Union(Plage, Plage4)
RempliList ListBox, Plage4
End If
'----------------------------------------
If Not IsMissing(Plage5) Then
Set Plage = Union(Plage, Plage5)
RempliList ListBox, Plage5
End If
'----------------------------------------
Set Ma_Feuille = ThisWorkbook.Worksheets(1)
Set Mon_Graphique = Ma_Feuille.Shapes.AddChart
With Mon_Graphique
.Top = Range("e12").Top
.Left = Range("e12").Left
.Height = Range("e12:h28").Height
.Width = Range("e12:h28").Width
.Name = CharTNamePLA
With .Chart
.SetSourceData Plage, xlRows
.SeriesCollection(1).XValues = "='" & Ma_Feuille.Name & "'!$D$7:$F$7"
.SeriesCollection(1).Name = Etiquette1
.SeriesCollection(2).Name = Etiquette2
.SeriesCollection(3).Name = Etiquette3
.SeriesCollection(4).Name = Etiquette4
.SeriesCollection(5).Name = Etiquette5
.ChartType = ChartTypePLA
.HasTitle = True
.ChartTitle.Text = ChartTitlePLA
End With
End With
Set Ma_Feuille = Nothing
Set Mon_Graphique = Nothing
Set Plage = Nothing
End Sub
Sub Macro2()
Dim Plage1 As Range, Plage2 As Range, Plage3 As Range, Plage4 As Range, Plage5 As Range
Dim Etiquette1 As String, Etiquette2 As String, Etiquette3 As String, Etiquette4 As String, Etiquette5 As String
Dim ChartTitleA As String, ChartNameA As String
Dim ChartTypeA As Integer
ChartTypeA = xlColumnClustered
ChartTitleA = "Key Financials"
ChartNameA = "Key Financials"
Set Plage1 = Worksheets(1).Range("I35:K35")
Set Plage2 = Worksheets(1).Range("I37:K37")
Set Plage3 = Worksheets(1).Range("I40:K40")
Set Plage4 = Worksheets(1).Range("I42:K42")
Set Plage5 = Worksheets(1).Range("I44:k44")
Etiquette1 = Worksheets(1).Range("G35")
Etiquette2 = Worksheets(1).Range("G37")
Etiquette3 = Worksheets(1).Range("G40")
Etiquette4 = Worksheets(1).Range("G42")
Etiquette5 = Worksheets(1).Range("G44")
Call Chart_PL_Analysis(Worksheets(1).ListBox1, ChartNameA, ChartTypeA, ChartTitleA, Plage1, Etiquette1, Etiquette2, Etiquette3, Etiquette4, Etiquette5, Plage2, Plage3, Plage4, Plage5)
End Sub |