Dynamic chart using VBA

acct_nael

New Member
Joined
Dec 11, 2016
Messages
3
Code:
Sub ACGC()
'
' ACGC Macro
'

'
    Sheets(Sheets.Count).Select
    Sheets.Add
    ActiveSheet.Name = "ACGC Graph"
    Cells.Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Range("A1").Select
    Sheets("VWAP").Select
    Range("B5:B6").Select
    Range(Selection, Selection.End(xlToRight)).Select
    ActiveSheet.Shapes.AddChart2(227, xlLineMarkers).Select
    ActiveChart.SetSourceData Source:=Range("VWAP!$B$5:$Q$6")
    [COLOR=#0000ff]ActiveChart.FullSeriesCollection(1).XValues = "==VWAP!Date"
    ActiveChart.FullSeriesCollection(1).Values = "==VWAP!ACGC"[/COLOR]
    ActiveChart.Parent.Cut
    Sheets("ACGC Graph").Select
    Range("B4").Select
    ActiveSheet.Paste
End Sub
Hello,

I get an application defined or object defined error when I try to run the code above. Can you please help? I have already defined the names using the name manager, so can't see a reason for this?

Thank you
 
Last edited by a moderator:

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
when you step through the code, which is the line that fails
 

Watch MrExcel Video

Forum statistics

Threads
1,122,564
Messages
5,596,875
Members
414,106
Latest member
Tigretto

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
Top