Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I'm trying to figure out how to define the source data range when the range
is not predetermined, when adding a chart in VBA. I can't just do "A1:B3", because it will be an unknown number of rows (though always two columns). If cells worked (as I've tried below), I could just use a variable for the appropriate row reference, but no go so far. Any ideas? Thanks a lot. With Charts(1) .Location whe=xlLocationAsNewSheet .SetSourceData Source:=Sheets("Sheet1").Range(Cells(1, 1), Cells(2, 2)), PlotBy:=xlColumns .ChartType = xlBarClustered End With |
#2
![]() |
|||
|
|||
![]()
Hi
Sub ChartRange() Dim r As Range, c As Chart With Sheets("Sheet1") Set r = .Range(.Range("A1"), _ ..Range("A" & Rows.Count).End(xlUp).Offset(0, 1)) End With Set c = Charts.Add c.Location Whe=xlLocationAsNewSheet, Name:="MyChart" c.SetSourceData Source:=r, PlotBy:=xlColumns End Sub -- XL2002 Regards William "D" wrote in message ... | I'm trying to figure out how to define the source data range when the range | is not predetermined, when adding a chart in VBA. I can't just do "A1:B3", | because it will be an unknown number of rows (though always two columns). If | cells worked (as I've tried below), I could just use a variable for the | appropriate row reference, but no go so far. Any ideas? Thanks a lot. | | With Charts(1) | .Location whe=xlLocationAsNewSheet | .SetSourceData Source:=Sheets("Sheet1").Range(Cells(1, 1), | Cells(2, 2)), PlotBy:=xlColumns | .ChartType = xlBarClustered | End With |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Individual labels to data point in Excel charts | Charts and Charting in Excel | |||
Excel 97 chart opened in Excel 2003 - Source Data problem | Charts and Charting in Excel | |||
Problem with graph ranges | Charts and Charting in Excel | |||
Formulas in source data | Charts and Charting in Excel | |||
Named dynamic ranges, copied worksheets and graph source data | Charts and Charting in Excel |