Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50165

A graph for each worksheet placed inside the pertained worksheet

$
0
0
Currently I am messing around with a smaller version of what I am attemping to do to figure this out. I ultimately would like to run a code that would go thorough all the sheets indivually and produce a graph placed for that specific worksheet. When I attempt to do this, all of the graphs are misplaced or placed on one sheet. Atm, the example of the excel would have number placed A1:B5

Code:

Sub DoToAll()

Dim ws As Worksheet

For Each ws In Worksheets



'Sheets(ws).Activate 'Tried something, didn't work


   
    ActiveSheet.Shapes.AddChart.Select
    'ws.Shapes.AddChart.Select' attempt to ws it
    ActiveChart.ChartType = xlXYScatterLines
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(1).XValues = ws.Range(ws.Cells(1, 1), ws.Cells(5, 1))

    ActiveChart.SeriesCollection(1).Values = ws.Range(ws.Cells(1, 2), ws.Cells(5, 2))
Next

End Sub


Viewing all articles
Browse latest Browse all 50165

Trending Articles