Ramballah
Active Member
- Joined
- Sep 25, 2018
- Messages
- 334
- Office Version
- 365
- Platform
- Windows
Hello all,
Can someone please tell me why my code is not looping?
It should be looping normally but it's not.
Can someone please tell me why my code is not looping?
It should be looping normally but it's not.
Code:
Sub AddCorrectRanges() Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
Dim rng5 As Range
Dim cel As Range
Dim i As Integer
Dim d As Integer
Set rng1 = Range("G2:J27") 'Entire chart
Set rng2 = Range("I3:J14") 'Values for statistics
Set rng3 = Range("I19:J27") 'Values for profits / losses
Set rng4 = Range("G2:J2") 'Current Session Statistics
Set rng5 = Range("G18:J18") 'Current Session Profits / Losses
Set cel = Range("I3")
For d = 0 To 5000
For i = 0 To 4
If d = 0 And i = 0 Then i = 1
If cel.Offset(30 * d, 5 * i) = "" Then
rng4.ClearContents
rng5.ClearContents
rng4.Value = "Session Statistics " & i + d * 5
rng5.Value = "Session Profits / Losses " & i + d * 5
rng1.Copy rng1.Offset(30 * d, 5 * i)
rng2.Offset(30 * d, 5 * i).ClearContents
rng3.Offset(30 * d, 5 * i).ClearContents
rng2.Copy
rng2.Offset(30 * d, 5 * i).PasteSpecial xlPasteValues
rng3.Copy
rng3.Offset(30 * d, 5 * i).PasteSpecial xlPasteValues
rng4.ClearContents
rng5.ClearContents
rng4.Value = "Current Session Statistics"
rng5.Value = "Current Session Profits / Losses"
GoTo TheEnd
End If
Next i
Next d
TheEnd:
Application.Calculation = xlCalculationAutomatic
End Sub