countryfan_nt
Well-known Member
- Joined
- May 19, 2004
- Messages
- 765
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!
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: