xlStockHLC

  • Thread starter Thread starter alldreams
  • Start date Start date
A

alldreams

Could anyone tell me why this macro breaks? I get
a "Method Charttype of object failed.

Sub Macro2()
Dim johann As ChartObject


Set johann = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=615, Top:=18, Height:=410)
johann.Chart.ChartType = xlStockHLC
johann.Chart.SetSourceData Source:=Sheets
("DATA").Range("U4:CD6"), PlotBy:= _
xlRows
johann.Chart.SeriesCollection(1).XValues = "=DATA!
R3C21:R3C82"
johann.Chart.SeriesCollection(1).Values = "=DATA!
R4C21:R4C82"
johann.Chart.SeriesCollection(2).XValues = "=DATA!
R3C21:R3C82"
johann.Chart.SeriesCollection(3).XValues = "=DATA!
R3C21:R3C82"
johann.Chart.Location Where:=xlLocationAsObject,
Name:="DATA"


End Sub

thanks for your help!
 
Move the SetDataSource line before the ChartType line:

Set johann = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=615, Top:=18, Height:=410)
johann.Chart.SetSourceData Source:=Sheets
johann.Chart.ChartType = xlStockHLC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top