emorris1000
Registered User.
- Local time
- Yesterday, 19:58
- Joined
- Feb 22, 2011
- Messages
- 125
Got a real strange one here. I'm sure its something obvious, but I can't figure it out.
I have a graph in excel I am building (from access). Here's the basic code:
Now, this works fine, but it uses explicit cell references which I don't like (since the length won't always be to J36). I would prefer to use my "lastrow" variable, which I use all over this module. The code I started with, which throws an error, is this:
I've checked the "lastrow" variable and it has the correct value, but every time I run this I get an application/object error (1004).
This is pretty basic stuff, so its really aggravating that I can't see where I screwed up.... help me with your better eyes.
I have a graph in excel I am building (from access). Here's the basic code:
Code:
xlbook.Charts.Add
xlbook.ActiveChart.ChartType = xlXYScatter
RemoveUnwantedSeries xlbook
'custom function that strips all of the garbage series vba adds automatically, works fine
Set xlSeries = xlbook.ActiveChart.SeriesCollection.NewSeries
'this is the code of interest
xlSeries.Name = xlsheet.Range("N1")
xlSeries.Values = xlsheet.Range("J4:J36")
xlSeries.XValues = xlsheet.Range("B4:B36")
Now, this works fine, but it uses explicit cell references which I don't like (since the length won't always be to J36). I would prefer to use my "lastrow" variable, which I use all over this module. The code I started with, which throws an error, is this:
Code:
With xlSeries
.name = xlsheet.range("N1")
.Values = xlsheet.Range(xlsheet.Cells(4, 10), xlsheet.Cells(Lastrow - 2, 2)) 'throws an error
.XValues = xlsheet.Range(xlsheet.Cells(4, 2), xlsheet.Cells(Lastrow - 2, 2)) 'throws an error
End With
I've checked the "lastrow" variable and it has the correct value, but every time I run this I get an application/object error (1004).
This is pretty basic stuff, so its really aggravating that I can't see where I screwed up.... help me with your better eyes.