A simplistic approach would be something like this. In the Define Names dialog
(Insert - Names - Define, or CTRL+F3), define a name such as this:
Name: ColumnA
Refers To:
=OFFSET(Sheet1!$A$1,0,0,COUNT(Sheet1!$A:$A),1)
Then in step 2 of the chart wizard, on the Series tab, for Values enter the
sheet-qualified range name:
=Sheet1!ColumnA
This could be readily automated using VBA:
Sub ChartDynamicColumns()
Dim rCol As Range
Dim rColName As Range
Dim sCol As String
Application.ScreenUpdating = False
For Each rCol In ActiveSheet.Columns
sCol = rCol.Address(ColumnAbsolute:=False)
sCol = Left(sCol, (Len(sCol) - 1) / 2)
ActiveWorkbook.Names.Add _
Name:="'" & ActiveSheet.Name & "'!Column" & sCol, _
RefersTo:="=OFFSET('" & ActiveSheet.Name & "'!$" & sCol & _
"$1,0,0,MAX(1,COUNT('" & ActiveSheet.Name & "'!$" & _
sCol & ":$" & sCol & ")),1)"
Set rColName = ActiveSheet.Range("Column" & sCol)
If WorksheetFunction.Count(rColName) 0 Then
With ActiveSheet.ChartObjects.Add(rColName.Left, 50, 200, 150).Chart
If .SeriesCollection.Count = 0 Then
.SeriesCollection.NewSeries
Else
Do While .SeriesCollection.Count 1
.SeriesCollection(1).Delete
Loop
End If
With .SeriesCollection(1)
.Values = "='" & ActiveSheet.Name & "'!Column" & sCol
End With
.ChartType = xlArea
End With
End If
Next
Application.ScreenUpdating = True
End Sub
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
No Such Luck wrote:
"Jon Peltier" wrote in message
...
You could look into dynamic named ranges for your source data ranges. Here
are a few examples and a lot of links:
http://peltiertech.com/Excel/Charts/Dynamics.html
Thanks, Jon.
I've actually tried several of the dynamic range tutorials without luck.
They all seemed to be geared toward a graph with data values and labels, but
I haven't been able to taylor them to work with my scenario. Could you,
perhaps, provide a very, very simple dynamic range solution for just a
column of data that will change in length (i.e., no labels, no column
headers (and thus, offsets), etc.) Just a simple column like:
4
3
8
1
6
1
4
whose area graph would automatically expand if you added two elements:
4
3
8
1
6
1
4
8
1