Welcome to the Forum,
Something like this would work, if you can't get it to work then please copy your code into your thread you'll get a better response/solution.
expression.
Add (
Left,
Top,
Width,
Height) deals with the positioning in the worksheet.
VBA Code:
Set co = Sheets("Sheet1").ChartObjects.Add(50, 40, 200, 100)
Thank you for youre respons.
I use the next code:
Sub Macro2()
Dim GrafiekNaam As String
Dim GrafiekNummer As String
Dim GrafiekDataSource As String
Dim GrafiekTitel As String
GrafiekNummer = Range("grafieknummer").Value
GrafiekNaam = "Grafiek " & GrafiekNummer
GrafiekDataSource = Range("GrafiekDataSource").Value
GrafiekTitel = Range("grafiektitel").Value
ActiveSheet.Shapes.AddChart2(332, xlLineMarkers).Select
ActiveChart.SetSourceData Source:=Range(GrafiekDataSource)
ActiveChart.ChartArea.Select
ActiveChart.SetElement (msoElementLegendBottom)
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.ChartTitle.Text = "Andere titel"
Selection.Format.TextFrame2.TextRange.Characters.Text = GrafiekTitel
With Selection.Format.TextFrame2.TextRange.Characters(1, 12).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 12).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With
Set co = Sheets("Marktprijs benadering").ChartObjects.Add(380, 15, 600, 400)
Set co = Sheets("Marktprijs benadering").ActiveChart.Add(380, 15, 600, 400)
Range("GrafiekNummer").Value = Range("GrafiekNummer").Value + 1
GrafiekNummer = Range("grafieknummer").Value
Range("V36").Select
End Sub
How do I use your solution in this code?
I tried it 2 ways, but they don't work well.