Next without For error

marimar02

Board Regular
Joined
May 21, 2010
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Does anyone know why I would be getting this error? It worked fine before I added 7 additional ranges and 7 additional strings. I've limited the rows to run from 13 to 20 for a test but it worked running 700 lines without an issue before adding ranges and strings to expand to other columns:

Code:
Sub Calculate_ActFcstBudLY()

Dim i As Integer
Dim rng1 As Range, rng2 As Range, rng3 As Range, rng4 As Range, rng5 As Range, rng6 As Range, rng7 As Range, rng8 As Range
Dim Dpndnt1 As String, Dpndnt2 As String, Dpndnt3 As String, Dpndnt4 As String, Dpndnt5 As String, Dpndnt6 As String, Dpndnt7 As String, Dpndnt8 As String, Dpndnt9 As String
Dim DeptNo As String
    
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .EnableEvents = False
        .DisplayAlerts = False
    End With
    
    For i = 13 To 20


    Set rng1 = Range("L" & i)
    Set rng2 = Range("N" & i)
    Set rng3 = Range("P" & i)
    Set rng4 = Range("R" & i)
    Set rng5 = Range("U" & i)
    Set rng6 = Range("W" & i)
    Set rng7 = Range("Y" & i)
    Set rng8 = Range("AA" & i)
    
    Dpndnt1 = Left(Range("L" & i).Formula, 4)
    Dpndnt2 = Left(Range("N" & i).Formula, 4)
    Dpndnt3 = Left(Range("P" & i).Formula, 4)
    Dpndnt4 = Left(Range("R" & i).Formula, 4)
    Dpndnt5 = Left(Range("U" & i).Formula, 4)
    Dpndnt6 = Left(Range("W" & i).Formula, 4)
    Dpndnt7 = Left(Range("Y" & i).Formula, 4)
    Dpndnt8 = Left(Range("AA" & i).Formula, 4)
    Dpndnt9 = Range("J" & i)
    
    If Dpndnt1 = "=SUM" Or Dpndnt9 = "Skip" Then
    If Dpndnt2 = "=SUM" Or Dpndnt9 = "Skip" Then
    If Dpndnt3 = "=SUM" Or Dpndnt9 = "Skip" Then
    If Dpndnt4 = "=SUM" Or Dpndnt9 = "Skip" Then
    If Dpndnt5 = "=SUM" Or Dpndnt9 = "Skip" Then
    If Dpndnt6 = "=SUM" Or Dpndnt9 = "Skip" Then
    If Dpndnt7 = "=SUM" Or Dpndnt9 = "Skip" Then
    If Dpndnt8 = "=SUM" Or Dpndnt9 = "Skip" Then
    
    GoTo CellSkip
    
    Else
    
'Calculate Month Actuals
    rng1.FormulaR1C1 = "omitted"

'Calculate Month Forecast
    rng2.FormulaR1C1 = "omitted"

'Calculate Month Budget
    rng3.FormulaR1C1 = "omitted"


'Calculate Month Last Year
    rng4.FormulaR1C1 = "=SUMIF(R4C110:R4C121,R4C18,RC[92]:RC[103])"


'Calculate YTD Actuals
    rng5.FormulaR1C1 = "=RC[23]"


'Calculate YTD Forecast
    rng6.FormulaR1C1 = "=RC[47]"


'Calculate YTD Budget
    rng7.FormulaR1C1 = "=RC[71]"


'Calculate YTD Last Year
    rng8.FormulaR1C1 = "=RC[95]"
    
    'rng.Value = rng.Value


    End If
    
CellSkip:
    
    Next i
    
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .EnableEvents = True
        .DisplayAlerts = True
    End With
    
End Sub

Thanks much...
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You have 8 If statements and only one End If - each If statement needs an End If.
 
Upvote 0

Forum statistics

Threads
1,223,779
Messages
6,174,492
Members
452,567
Latest member
ONEIL290

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