PDA

View Full Version : Help with Creating Graphs bars where source data changes



jazzyt2u
09-05-2008, 03:44 PM
Hi,
I have a couple of questions.
1) I'm trying to create bar graphs using the following coding and I'm having problems. The code works great until line 17. When I get here it creates the range as K2:M16 instead of K2:M2, K16:M16 like I set for ranges My1 and My2. This causes the copied graph to have problems


Sub Copy_PasteGraphs()
Dim My1, My2 As Range

Sheets("DC2").Activate
Range("K2:M2").Select

Set My1 = Selection
Range("K16:M16").Select
Set My2 = Selection

Sheets("DC2Chart").Activate
Range("D15").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Copy
ActiveWindow.Visible = False
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
ActiveChart.SetSourceData Source:=Sheets("DC2").Range(My1, My2), _
PlotBy:=xlColumns ' HERE IS WHERE I"M HAVING PROBLEMS
End Sub



2) different reports will have different number of breakdowns. I have a counta formula letting me know how many breakdowns there are. This data exists for example in cell F19. How do I incorporate this value into a For...Next statement to do the above coding (with minor adjustments) that number of times?

3) I will also need to insert rows based on this counta value as well.

I would really appreciate some :help
</IMG>