p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Excel VBA (http://p2p.wrox.com/forumdisplay.php?f=79)
-   -   Variable data ranges for charts (http://p2p.wrox.com/showthread.php?t=417)

Cclhodges June 11th, 2003 04:15 AM

Variable data ranges for charts

I want to create a chart with the data range dependant on certain variables. have tried the following to no effect any ideas?

i.e. .Range(.cells(x,y),.cells(i,j))

I have tried several variations but none are accepted

The actual code line is:

ActiveChart.SetSourceData Source:=Sheets(Country(i, 1)).Range(Cells(2, 2), Cells(2, maxdate - 1987))

Any suggestions appreciated.

phil June 12th, 2003 02:18 AM

Are you getting an error message? If so, what?

Two things to check

1. Does Country(i,1) return a string or a long/integer corresponding to an existing sheet.

2. Is maxdate a date or a long/integer?
If date try ...., Cells(2,DatePart("yyyy",maxdate)-1987), also checking that the year of maxdate>=1989

Adding the following above the line should tell you which is the problem
Debug.Print Country(i, 1); maxdate

All times are GMT -4. The time now is 11:15 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.