Speeding up the Loop code.

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
758
Hello friends, Hope all is well!

Please help me speed up the Loop code. The code is running OK; But too slow.

Thank you so much!


Code:
Sub B_REV()

Dim aSeries As Series
         ActiveSheet.ChartObjects("Chart 9").Select
    
    For Each aSeries In ActiveChart.SeriesCollection
        Select Case UCase(aSeries.Name)
        Case "REV"
        Case Else
            aSeries.Delete
            End Select
        Next aSeries
          
' Track elapsed time for procedure
    st = Now()
' Establish wait period - fraction of day
' Data Set
    num_rows = Sheet6.Range("A1").CurrentRegion.Rows.Count - 1
' Establish new series for last point on trend line
        ActiveChart.SeriesCollection.NewSeries
                ActiveChart.SeriesCollection(2).XValues = Sheets("REV").Cells(2, 1)
                ActiveChart.SeriesCollection(2).Values = Sheets("REV").Cells(2, 2)
' Loop through source data, copy to dynamic chart range
 For r = 2 To num_rows
     Sheets("REV").Cells(r, 4) = Sheets("REV").Cells(r, 1)
    Sheets("REV").Cells(r, 5) = Sheets("REV").Cells(r, 2)
    ActiveChart.SeriesCollection(2).XValues = Sheets("REV").Cells(r, 4)
    ActiveChart.SeriesCollection(2).Values = Sheets("REV").Cells(r, 5)
    ' Check to see if user wants animated chart
            If Sheets("chart").Range("AJ1") = "True" Then
            Application.Wait (Now + TimeValue("0:00:02") / 2)
        End If
    Next r
' Remove trend point series
        ActiveChart.SeriesCollection(2).Delete
 Range("a1").Select
End Sub
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Which loop is slowing things down?
 
Upvote 0
If that's what's slowing down the code why not remove it?
 
Upvote 0
The purpose of the loop is to show a semi automated growing chart. the chart increases but too slow.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,803
Members
449,048
Latest member
greyangel23

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