Private Sub CommandButton1_Click()
Dim i As Integer
Dim r1, r2, ranges As Range
Dim DebutX As Integer
Dim FinX As Integer
Dim j As Integer
Dim k As Integer
' Pour Définir le numéro de la ligne à utiliser...
If Cbo_device.Value = "a" Then
i = 2
ElseIf Cbo_device.Value = "b" Then
i = 3
ElseIf Cbo_device.Value = "c" Then
i = 4
ElseIf Cbo_device.Value = "d" Then
i = 5
ElseIf Cbo_device.Value = "e" Then
i = 6
ElseIf Cbo_device.Value = "f" Then
i = 7
End If
'Pour définir le numéro de la collone à utiliser
For j = 2 To 256
If j = cbo_debut.Value Then
ActiveCell.Columns = DebutX
End If
Next j
For k = 2 To 256
If k = cbo_fin.Value Then
ActiveCell.Columns = FinX
End If
Next
'Maintenant pour définir le range du graph, il fonctionne avec les i et si je spécifie le numéro de la collone, mais avec la variable pour la collone ca ne fonctionne plus...
Set r1 = Sheets("Data").Range(Cells(1, DebutX), Cells(1, FinX))
Set r2 = Sheets("Data").Range(Cells(i, DebutX), Cells(i, FinX))
Set ranges = Union(r1, r2)
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=ranges, PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Graph Alliance"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
End Sub