Link to home
Start Free TrialLog in
Avatar of jlcannon
jlcannon

asked on

Excel

Experts,

I am in Excel and trying to set source data for a graph using vba. The problem is, my source data is always changing so I want to use end(xlDown) in the range. However, every time I try to run this code, I get run-time error 1004: aplication-defined or object-defined error. Any Ideas?

Sub TempGraph()
'
    Sheets("Report").Select
    ActiveSheet.ChartObjects("TempGraph").Activate
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Sheets("Data").Range("Q2", Range("Q2").End(xlDown))

End Sub

Open in new window

Thank you for the help
Avatar of etech0
etech0
Flag of United States of America image

If you give it a specific range, eg: Range("Q2","Q3"), does the code work? Let's make sure that that is the problem.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jlcannon
jlcannon

ASKER

Yes,  using Range("Q2","Q3") works fine
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial