Make a graph with for cycle

F

ferrdav

Good Morning,

i get this problem: i have a worksheet like this:



A B C D
1 10/03 2 10/03 45
2 11/03 6 11/03 85
3 12/03 8 12/03 96
4 13/03 3 13/03 52


what i would like to do is a macro that make a graph taking columns A&B
and then a second grafh taking columns C&D and so on...

i wrote this, but it does not work (in my spreadsheet i get 146 columns
and 256 rows...):

For i = 1 To 146
Range(.Cells(i, 2), .Cells(i + 1, 256)).Select
Range(Selection, Selection.End(xlDown)).Select
Charts.Add
ActiveChart.ChartType = xlAreaStacked
ActiveChart.SetSourceData
Source:=Sheets("INDUSTRIALS").Range(.Cells(i, 2), .Cells(i + 1, 256)),
_
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject,
Name:="INDUSTRIALS"
With ActiveChart
HasTitle = True
ChartTitle.Characters.Text = "Asset Swap Spread Bid"
Axes(xlCategory, xlPrimary).HasTitle = False
Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.Legend.Select
Selection.Delete
Next i
End Sub


any help? thank you!
 
T

Tushar Mehta

<snip}
i wrote this, but it does not work (in my spreadsheet i get 146 columns
and 256 rows...):
<snip>

How does it not work?

Also, what is your intent? One chart with 73 series in it? Or 73
charts with 1 series in each? Of course, neither seems aesthetically
appealing.

You might also want to check the Excel | Tutorials | 'Dynamic Charts'
page of my web site. One of the examples addresses how to select one
column from a list of many as the source for a chart.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top