create new charts based on defined names list

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I have two list:
M1_LIST = values (like 1, 5, 6 etc)
Country_all_list = values names (Audi, BMW etc)

Now I'm creating chart:
Code:
Dim charts_1 As ChartObject
Set charts_1 = sCountry.ChartObjects.Add(Left:=300, Top:=175, Width:=400, Height:=300)

With charts_1
    .Chart.ChartType = xlColumnClustered
    .Chart.SeriesCollection(1).Values = "=M1_LIST"
    .Chart.SeriesCollection(1).XValues = "=Country_all_list"
End With


But I'm getting error about "Invalid Parameter".
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I changed it:

Code:
With mychrt
    .SeriesCollection.NewSeries
    .Legend.Select
    .SetElement (msoElementLegendNone)
    .SeriesCollection(1).Name = Country.Range("E9")
    .SeriesCollection(1).XValues = Country.Range("F9:F15")
    .SeriesCollection(1).Values = Country.Range("A9:A15")

End With

What is wrong here?
xvalues- numbers like 3, 8, 12, 4....
values- audi, bmw, vw, mer.....
 
Upvote 0
works:
Code:
Set Country = wb_c.Worksheets("Country lvl")


Dim mychrt As Chart
Set mychrt = Country.Shapes.AddChart.Chart


    With mychrt
    .SeriesCollection.NewSeries
    .Legend.Select
    .ChartType = xlColumnStacked
    .SetSourceData Source:=Country.Range("E9:E15"), PlotBy:=xlColumns
    .SetElement (msoElementLegendNone)
    .SeriesCollection(1).Name = Country.Range("E8")
    .SeriesCollection(1).XValues = Country.Range("D9:D15")
    .SeriesCollection(1).ApplyDataLabels

how to change chart position?
 
Upvote 0
resolved:
Code:
    .ChartArea.Left = 200
    .ChartArea.Top = 400
    .ChartArea.Width = 500
    .ChartArea.Height = 200
 
Upvote 0

Forum statistics

Threads
1,215,131
Messages
6,123,222
Members
449,091
Latest member
jeremy_bp001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top