Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2003, 04:15 AM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Variable data ranges for charts

Hi

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.
 
Old June 12th, 2003, 02:18 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on Hiding Charts with no data Wazar Excel VBA 4 December 19th, 2018 03:04 AM
Date Ranges nbuckwheat Access 1 December 12th, 2005 12:45 PM
Copying ranges mtowle Excel VBA 2 November 2nd, 2005 06:35 AM
date ranges yuqlin BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 December 23rd, 2004 05:23 PM
Variable data Ranges dgarcia1128 Excel VBA 3 June 20th, 2003 02:11 PM





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