Creating charts in every worksheet

eurano

New Member
Joined
Sep 13, 2015
Messages
25
Hi
The code below runs EXTREMELY slow. Somebody know the reason?



Code:
Sub WorksheetLoop()


    Dim WS As Worksheet, co As Object


    For Each WS In ActiveWorkbook.Worksheets


        Set co = WS.Shapes.AddChart()


'        ActiveSheet.Range("P2:AB2153").Select


        'adjust to suit...
        co.Top = 105
        co.Left = 450
        co.Width = 900
        co.Height = 300


        With co.Chart
        
        
        
        .ChartType = xlLine


  Do Until .SeriesCollection.Count = 0
    .SeriesCollection(1).Delete
  Loop
  
  
  With .SeriesCollection.NewSeries
    .Name = "=""Temperatura"""
    .XValues = Range(Range("b2"), Range("b2").End(xlDown))
    .Values = Range(Range("a1"), Range("a2").End(xlDown))
  End With


With .SeriesCollection.NewSeries
    .Name = "=""Niedozwolona"""
    .XValues = Range(Range("b2"), Range("b2").End(xlDown))
    .Values = Range(Range("c1"), Range("c2").End(xlDown))
  End With


With .SeriesCollection.NewSeries
    .Name = "=""Niedopuszczalna"""
    .XValues = Range(Range("b2"), Range("b2").End(xlDown))
    .Values = Range(Range("d1"), Range("d2").End(xlDown))








End With
            
            
            
        
            
            
        End With


Set co = Nothing
        Debug.Print "Processed: " & WS.Name


    Next WS
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Well, there's apparently a lot of data in the chart when you start.

When you originally recorded your code, you had selected a large range, then you're not really using it. Instead, select something smaller, like "B1:C2".

Then you should clear the chart data before you set the chart type. In your code, you had all that data in the chart, then you changed the chart type and had to wait for Excel to redraw the chart one series at a time.
 
Upvote 0

Forum statistics

Threads
1,223,943
Messages
6,175,552
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top