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:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
when you step through the code, which is the line that fails
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,920
Members
448,533
Latest member
thietbibeboiwasaco

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