Macro for Graph

ajc5382

New Member
Joined
Jun 25, 2012
Messages
41
Hi all,

I'm having serious issues trying to record macros to create graphs in my model. I used the macro recorder to go and select the data to create graphs in hopes that every time I change the data, the graphs would change with my vba code. However, every time I refresh the data it doesn't work and the source data for each graph says "#ref." How can I record/write code for graphs so that I can meet my desired goal.

Code:
Sub Macro1()'
' Macro1 Macro
' Macro recorded 7/18/2012
'
' Keyboard Shortcut: Ctrl+f
'
    Charts.Add
    ActiveChart.ChartType = xlLine
    ActiveChart.SetSourceData Source:=Sheets("INFO").Range("A:A,G:G,H:H,I:I"), _
        PlotBy:=xlColumns
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Correlations"
    ActiveChart.HasDataTable = False
    ActiveChart.SeriesCollection(3).Select
    ActiveChart.SeriesCollection(3).AxisGroup = 2
    ActiveChart.PlotArea.Select
    ActiveChart.SeriesCollection(3).Select
    ActiveChart.SeriesCollection(3).ChartType = xlLine
    ActiveChart.SeriesCollection(2).Select
    ActiveChart.SeriesCollection(2).AxisGroup = 2
    ActiveChart.SeriesCollection(2).ChartType = xlLine
    ActiveSheet.Shapes("Chart 15").IncrementTop -154.5
    Windows("Project 1AA.xls").SmallScroll Down:=-21
    ActiveSheet.Shapes("Chart 15").ScaleWidth 1.17, msoFalse, msoScaleFromTopLeft
    ActiveChart.PlotArea.Select
    Selection.Width = 515
    ActiveChart.Legend.Select
    Selection.Left = 35
    Selection.Top = 191
    Windows("Project 1AA.xls").SmallScroll Down:=-6
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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