Pie Chart Macro Help

  • Thread starter Thread starter David Evans
  • Start date Start date
D

David Evans

Hi,

I'm working on a macro that will auto-gerate a Pie Chat based upon
list of data. This list of data can vary from being 2 rows to 100
Being utterly useless at Excel VB, is there a simple loop that wil
find the first and last points of the data?

i.e

------A------B
1 data1 4
2 data2 6
3 data3 2
4 data4 5
5 data5 88

So it then figures out that the data range is A1:B5

What do i then need to change in the function below, to look at th
range it has just found in the above search?

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:B5")
PlotBy _
:=xlColumns

Thanks
David Evan
 
Even easier. Make sure there is a cushion of empty cells all around the
data. Then use this line:

ActiveChart.SetSourceData _
Source:=Sheets("Sheet1").Range("A1").CurrentRegion, _
PlotBy:=xlColumns

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

Andy said:
Hi David,

How about this,
Sub x()
Dim strEndCell As String
strEndCell = Range("B2").End(xlDown).Address
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:" &
strEndCell), PlotBy:=xlColumns
End Sub

For a non VBA solution have a look at the dynamic chart examples on Jon
and Tushar's sites.
http://peltiertech.com/Excel/Charts/Dynamics.html
http://www.tushar-mehta.com/

Cheers
 
Thanks a lot guys !

I think Andy Pope's method is better, as the data will most likely b
raw .csv data output from a database.

I'll probably be back with more problems later on when I get a bi
further o
 
Back
Top