I am using Excel 2007, but my code is sometimes run by users with Excel 2003.
I am trying to create a chart in a worksheet (I believe this is called a ChartObject). My code DOES create a chart, but it is blank. I need to figure out how to populate the chart with data the data found in the first four rows of the code.
I have tried everything I can think of, including reading Jon Peltier's dynamic charting instructions (which seems to be over my head).
Here is my code:
I have one line of code commented out using '. This is because this line of code gives me an error. I believe it is because of the Range(Selection) portion of the line. What I wanted this line of code to do is use the ChartWizard and use the first four lines of code (which selects the table of data) as the Range.
Can anyone help me figure out how to populate the chart and/or fix my code?
Thanks,
Lidsavr
I am trying to create a chart in a worksheet (I believe this is called a ChartObject). My code DOES create a chart, but it is blank. I need to figure out how to populate the chart with data the data found in the first four rows of the code.
I have tried everything I can think of, including reading Jon Peltier's dynamic charting instructions (which seems to be over my head).
Here is my code:
Code:
Range("A37").Select
r = Range("A37").End(xlDown).Row
c = Range("A37").End(xlToRight).Column
Range(Range("A37"), Cells(r, c)).Select
Dim cht1 As ChartObject
Set cht1 = ActiveSheet.ChartObjects.Add(100, 100, 720, 370.08)
' cht1.Chart.ChartWizard ActiveSheet.Range(Selection), Gallery:=xlColumnCluster, _
PlotBy:=xlRows, HasLegend:=True, Title:=drng
Sheets("232 Data").Select
ActiveSheet.ChartObjects(1).Select False
Selection.Cut
Sheets("232 Charts").Select
Range("A3").Select
ActiveSheet.Paste
CutCopyMode = False
Worksheets("232 Charts").Select
ActiveSheet.ChartObjects(1).Select False
I have one line of code commented out using '. This is because this line of code gives me an error. I believe it is because of the Range(Selection) portion of the line. What I wanted this line of code to do is use the ChartWizard and use the first four lines of code (which selects the table of data) as the Range.
Can anyone help me figure out how to populate the chart and/or fix my code?
Thanks,
Lidsavr