Nested Loops & IF Statements

danbrawl93

New Member
Joined
Dec 15, 2016
Messages
17
Hey guys,

I have the following code and I keep getting a "next without for" error, although I can't seem to debug it! I've tried to strip the code to its raw "For" and "If" statements.

Code:
If existing_sheet = 1 Then

For x = i + 1 To i + 100

    If Worksheets("Master Fee Table").Cells(x, MNC).Value = "" Then
        Exit For
        Else:
    End If

    If WorksheetFunction.CountIf(Range("A3:A1000"), mandate_no) > 0 Then
        Else:
    End If

    If existing_mandate = 1 Then
        For y = 3 To 1000
    
            If WorksheetFunction.Count(Range(Cells(y, 1), Cells(1000, 1))) = 0 Then
                Exit For
            End If

            If Cells(y - 1, 1).Value = mandate_no And Cells(y, 2).Value = "Portfolio No." Then
                For z = 4 To 1000
                    If Cells(y, z).Value = "" Then
                    Exit For
                    End If
                Next z                
            End If
    
            If Cells(y, 1).Value = mandate_no And InStr(1, Cells(y, 2), mandate_no) > 0 Then
            End If
    
        Next y

        For y = 3 To 10000
    
            If WorksheetFunction.Count(Worksheets("Portfolio").Range(Cells(y, 16), Cells(1000, 16))) = 0 Then
                Exit For
            End If
    
            If WorksheetFunction.CountIf(Range("B5:B1000"), Worksheets("Portfolio").Cells(y, 16)) = 0 Then
            End If
    
        Next y
Next x
End If

Can anybody help me out by finding how the code needs to be adjusted? Thanks so much!!! :)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You are missing an 'End If' above the last 'Next'

Code:
End If
Next x
End If
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,328
Messages
6,124,299
Members
449,149
Latest member
mwdbActuary

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