Excel Macro boucle
delili
-
delili -
delili -
Salut,
Dans mon tableau sous excel, j'ai des données sur une même colonne et j'aimerais faire une série de graphique avec une boucle pour avoir un graphique toute les 12 lignes
ci dessous la macro que j'ai enregistrée grace à excel et que j'ai bidouillée ensuite :
'Dim i As Integer
'Dim lig1 As Integer,lig1 = 2(ligne ou je voudrais que ma macro commence)
'Dim lig2 As Integer,lig2 = 13 (ligne ou je voudrais que ma macro finisse)
For i = 1 To 28(j'ai 28 graph à faire)
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("cat10_20").Range("D2:D13"), PlotBy:="xlColumns"
ActiveChart.Location Where:=xlLocationAsObject, Name:="cat10_20"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
lig1 = lig1 + 12
lig2 = lig2 + 12
Next i
End Sub
Je pense que je dois intégrer mes variables dans Range mais j'y connais pas grand chose.
Merci à tous ceux qui pourront m'aider.
Dans mon tableau sous excel, j'ai des données sur une même colonne et j'aimerais faire une série de graphique avec une boucle pour avoir un graphique toute les 12 lignes
ci dessous la macro que j'ai enregistrée grace à excel et que j'ai bidouillée ensuite :
'Dim i As Integer
'Dim lig1 As Integer,lig1 = 2(ligne ou je voudrais que ma macro commence)
'Dim lig2 As Integer,lig2 = 13 (ligne ou je voudrais que ma macro finisse)
For i = 1 To 28(j'ai 28 graph à faire)
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("cat10_20").Range("D2:D13"), PlotBy:="xlColumns"
ActiveChart.Location Where:=xlLocationAsObject, Name:="cat10_20"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
lig1 = lig1 + 12
lig2 = lig2 + 12
Next i
End Sub
Je pense que je dois intégrer mes variables dans Range mais j'y connais pas grand chose.
Merci à tous ceux qui pourront m'aider.
A voir également:
- Excel Macro boucle
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Si ou excel - Guide
- Déplacer colonne excel - Guide
2 réponses
Bonjour,
Sugestion (pas testé) :
Dim I As Integer
Dim Lig1 As Integer
Dim Lig2 As Integer
Dim Plage As String
Lig1 = 2 '(ligne ou je voudrais que ma macro commence)
Lig2 = 13 '(ligne ou je voudrais que ma macro termine)
For i = 1 To 28 '(j'ai 28 graph à faire)
Plage= ( "D" & Lig1 & ":D" & Lig2 )
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("cat10_20").Range(Plage), PlotBy:="xlColumns"
ActiveChart.Location Where:=xlLocationAsObject, Name:="cat10_20"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
Lig1 = Lig1 + 12
Lig2 = Lig2 + 12
Next i
End Sub
Lupin
~L'essentiel est invisible pour les yeux~
~On ne voit bien qu'avec le coeur~
Sugestion (pas testé) :
Dim I As Integer
Dim Lig1 As Integer
Dim Lig2 As Integer
Dim Plage As String
Lig1 = 2 '(ligne ou je voudrais que ma macro commence)
Lig2 = 13 '(ligne ou je voudrais que ma macro termine)
For i = 1 To 28 '(j'ai 28 graph à faire)
Plage= ( "D" & Lig1 & ":D" & Lig2 )
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("cat10_20").Range(Plage), PlotBy:="xlColumns"
ActiveChart.Location Where:=xlLocationAsObject, Name:="cat10_20"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
Lig1 = Lig1 + 12
Lig2 = Lig2 + 12
Next i
End Sub
Lupin
~L'essentiel est invisible pour les yeux~
~On ne voit bien qu'avec le coeur~