A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

auto data source, removing null



 
 
Thread Tools Display Modes
  #1  
Old July 3rd, 2007, 12:24 PM posted to microsoft.public.excel.charting
OTWarrior via OfficeKB.com
external usenet poster
 
Posts: 23
Default auto data source, removing null

I have a chart that is automatically generating a chart based on the data
imported into the spreadsheet, however, the number of rows of data is not the
same, so when the chart generates based on a selection that has more rows
selected than there is data for, it creates a very weird looking chart.

.Columns("A:B").Select
.Charts.Add
.ActiveChart.ChartType = xlColumnClustered
.ActiveChart.SetSourceData Source:=Sheets("Bookings Made").Range
("A1:B24"), PlotBy:=xlColumns

(NB: I am using with statments for ease of use)

as you can see, the range is set to ("A1:B24"), but I need it to be more
dymanic. I tried using ("A:B"), but that pulls the same error (as it is
looking for data which isn't there in B30 for example)

should I use some sort of length checker to see what the last row with data
is? and how would I do it?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200707/1

  #2  
Old July 3rd, 2007, 02:08 PM posted to microsoft.public.excel.charting
Jon Peltier
external usenet poster
 
Posts: 5,018
Default auto data source, removing null

You could use

Source:=Sheets("Bookings Made").Range("A1").CurrentRegion

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"OTWarrior via OfficeKB.com" u33269@uwe wrote in message
news:749dee750b5d5@uwe...
I have a chart that is automatically generating a chart based on the data
imported into the spreadsheet, however, the number of rows of data is not
the
same, so when the chart generates based on a selection that has more rows
selected than there is data for, it creates a very weird looking chart.

Columns("A:B").Select
.Charts.Add
.ActiveChart.ChartType = xlColumnClustered
.ActiveChart.SetSourceData Source:=Sheets("Bookings
Made").Range
("A1:B24"), PlotBy:=xlColumns

(NB: I am using with statments for ease of use)

as you can see, the range is set to ("A1:B24"), but I need it to be more
dymanic. I tried using ("A:B"), but that pulls the same error (as it is
looking for data which isn't there in B30 for example)

should I use some sort of length checker to see what the last row with
data
is? and how would I do it?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200707/1



  #3  
Old July 3rd, 2007, 04:56 PM posted to microsoft.public.excel.charting
OTWarrior via OfficeKB.com
external usenet poster
 
Posts: 23
Default auto data source, removing null

Just figured out I can use Dcount to count the query, all i need to do is add
one to it.

eg:

((DCount("*", "Query1")) + 1)

.ActiveChart.SetSourceData Source:=Sheets("Bookings received").Range("A1:B" &
((DCount _("*", "Query1")) + 1)), PlotBy:=xlColumns

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200707/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:03 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.