OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for any suggestions and I will give feedback on them.
I get the following error "Compile error: Next without for on
I get the following error "Compile error: Next without for on
Code:
Next i
Code:
Sub ClearCFData()
'Dimensioning
Dim i As Integer
Dim RowNumber As Long
'Turn Off Screen Updating
Application.ScreenUpdating = False
'Activating Sheet1
Worksheets("Sheet1").Activate
'Selecting Data and Clearing Values
'Setting the Starting Value of the RowNumber
RowNumber = 4
'Start Loop
For i = 1 To 7
Range("B" & RowNumber & ":WD" & (RowNumber + 2)).ClearContents
RowNumber = RowNumber + 4
Range("B" & RowNumber & ":WD" & (RowNumber + 2)).ClearContents
RowNumber = RowNumber + 4
Range("B" & RowNumber & ":WD" & (RowNumber + 2)).ClearContents
RowNumber = RowNumber + 4
Range("B" & RowNumber & ":WD" & (RowNumber + 1)).ClearContents
RowNumber = RowNumber + 5
Range("B" & RowNumber & ":WD" & (RowNumber + 1)).ClearContents
RowNumber = RowNumber + 15
Range("B" & RowNumber & ":WD" & (RowNumber + 1)).ClearContents
'Setting the RowNumber for the Next Set of Data
If i <= 3 Then
RowNumber = RowNumber + 8
If i = 4 Then
RowNumber = 164
If i > 4 And i < 8 Then
RowNumber = RowNumber + 80
End If
Next i
'Puts the ending mark back
Range("WF28").Copy Range("WF1:WF482")
'Sets the cursor at the begining
Worksheets("Sheet1").Activate
Range("B4").Select
'Turn On Screen Updating
Application.ScreenUpdating = True
'Calculate and Turn on Automatic Calculation
Calculate
Application.Calculation = xlAutomatic
End Sub