Ramballah
Active Member
- Joined
- Sep 25, 2018
- Messages
- 334
- Office Version
- 365
- Platform
- Windows
Hey so im working on a script where im copying charts everytime and stuff but for every loop i want to autoincrement aka show which loop it is.
in my code below the copy stuff works fine but i just need in the line rng4.Value = "Chart " & (d + i) something changed to make it work but idk how. What it does now is only show the i. it goes from 1 to 5 correctly. but it wont addup the d. Someone please help
in my code below the copy stuff works fine but i just need in the line rng4.Value = "Chart " & (d + i) something changed to make it work but idk how. What it does now is only show the i. it goes from 1 to 5 correctly. but it wont addup the d. Someone please help
Code:
Sub CopyToCorrectRanges() Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
Dim cel As Range
Dim d As Integer
Dim i As Integer
Set rng1 = Range("A1:H102")
Set rng2 = Range("B3:D102")
Set rng3 = Range("F3:H102")
Set rng4 = Range("A1:H1")
Set cel = Range("B3")
For d = 0 To 5000
For i = 0 To 4
If d = 0 And i = 0 Then i = 1
If cel.Offset(103 * d, 9 * i) = "" Then
rng4.Value = "Chart " & (d + i)
rng1.Copy rng1.Offset(103 * d, 9 * i)
rng2.ClearContents
rng3.ClearContents
rng4.ClearContents
GoTo TheEnd
End If
Next i
Next d
TheEnd:
Application.Calculation = xlCalculationAutomatic
End Sub