Macro Debugging - Charts

Jfrusty

New Member
Joined
Jun 1, 2020
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
Trying to get a set of data to graph via macro. New to debugging a macro as this is the second one I've done. After a few attempts and forum surfing I haven't found a solution that works. Used record to start and this is the line item it generated that has an issue:

1591042114524.png
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
VBA Code:
ActiveChart.SetSourceData Source:=Range(
        "'Average Days To Sell-30101-Mont'!$A$1:$A$66,'Average Days To Sell-30101-Mont'!$C$1:$C$66,'Average Days To Sell-30101-Mont'!$D$1:$D$66" _
        )
 
Upvote 0
Is your data range valid? Can you run this code without getting a 'chart range invalid' message? Are you getting other error messages?

VBA Code:
Sub ChartRangeTest()
    Dim ChartSourceRange As Range

    On Error Resume Next
    Set ChartSourceRange = Range("'Average Days To Sell-30101-Mont'!$A$1:$A$66,'Average Days To Sell-30101-Mont'!$C$1:$C$66,'Average Days To Sell-30101-Mont'!$D$1:$D$66")
    On Error GoTo 0
    
    If ChartSourceRange Is Nothing Then
        MsgBox "The source range for this chart is not valid", vbOKOnly Or vbExclamation, "Worksheet: " & ActiveSheet.Name
    Else
    ActiveChart.SetSourceData Source:=ChartSourceRange
    End If
End Sub
 
Upvote 0
Error code is

runtime error 1004 : Method range of object - 'Global' failed
 
Upvote 0
What happened when you ran the code I posted?
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,229
Members
448,879
Latest member
VanGirl

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