Insertion Graph par VBA
Bonjour je suis actuellement en train d'essayer d'inserer un graph à un endroit bien précis d'un feuille par ex (feuil1) et plage ( F5:O40).
Je voudrais aussi que celui ci soit entièrement transparent je bloque sur ces points là si quelqu'un peux me guider.
Voici mon code :
Dim Grf As ChartObject
Dim Sh As Worksheet
Set Sh = Sheets("ASP")
'On supprime tous les graphiques
For Each Grf In Sh.ChartObjects
Grf.Delete
Next Grf
'On crée notre graphique
Set Grf = Sh.ChartObjects.Add(140, 10, 500, 300)
With ActiveSheet.ChartObjects(1)
.Left = Range("F5:O40").Left
.Top = Range("F5:O40").Top
.Width = Range("F5:O40").Width
.Height = Range("F5:O40").Height
End With
With Grf.Chart
.ChartType = xlLineMarkers
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Values = Sh.Range("D2" & [A65536].End(xlUp).Row)
.XValues = Sh.Range("B2:B" & [A65536].End(xlUp).Row)
End With
.PlotVisibleOnly = False
End With
Set Grf = Nothing
Set Sh = Nothing
Merci d'avance
Malgré de multiple essai je n'y arrive toujours pas voilà mon avancé mais toujours pas concluant
Dim Grf As ChartObject
Dim Sh As Worksheet
Set Sh = Sheets("ASP")
'On supprime tous les graphiques
For Each Grf In Sh.ChartObjects
Grf.Delete
Next Grf
'On crée notre graphique
Set Grf = Sh.ChartObjects("Reaction Time").Add(140, 10, 500, 300)
With ActiveSheet.Shapes("Reaction Time")
.Left = Range("F5").Left
.Top = Range("F5").Top
End With
With Grf.Chart
.ChartType = xlLineMarkers
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Values = Sh.Range("D2:D" & [A65536].End(xlUp).Row)
.XValues = Sh.Range("B2:B" & [A65536].End(xlUp).Row)
End With
.PlotVisibleOnly = False
End With
Set Grf = Nothing
Set Sh = Nothing
End Sub
Bonjour,
Essaie ainsi :
* pour le transparence, tu préciseras ta demande.
Option Explicit
Public Sub DEMO()
Dim sh As Worksheet
Dim shp As Shape
Dim ch As Chart
Dim lRow As Long
Application.ScreenUpdating = False
Set sh = ActiveWorkbook.Worksheets("ASP")
lRow = sh.Cells(Rows.Count, 2).End(xlUp).Row
On Error Resume Next
sh.Shapes("Reaction Time").Delete
On Error GoTo 0
Set shp = sh.Shapes.AddChart
With shp
.Name = "Reaction Time"
.Left = sh.Range("F5:O40").Left
.Top = sh.Range("F5:O40").Top
.Width = sh.Range("F5:O40").Width
.Height = sh.Range("F5:O40").Height
End With
Set ch = shp.Chart
With ch
.ChartType = xlLineMarkers
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.XValues = sh.Range("B2:B" & lRow)
.Values = sh.Range("D2:D" & lRow)
End With
.PlotVisibleOnly = False
End With
Set ch = Nothing: Set shp = Nothing: Set sh = Nothing
End Sub
Bonjour,
Tu penses donner de tes nouvelles
Cdlt.