mardi 15 janvier 2019

If statement within a For-Loop

I'm trying to have a for loop go through a column to find "No" and if "No" is not found it outputs "Yes" in a different cell. So my thought process is having the for-loop and then an if statement saying that if the cell says "Yes" or "No Requirement" then it continues looking for a "No" and if a "No" isn't found it outputs "Yes" and if it is found the loop stops and it outputs "No".

I'm making a tool to pull data from different sheets on the same excel workbook.

Sub PleaseWork()

Dim matrix(i, j) As Double


For i = 26 To 33
    For j = 8 To 8
        If Worksheets("Calculations").Range(i, j) = "Yes" Or "No Requirement" Then
            Worksheets("Calculations").Range("H33").Value = "Yes"
            Next i
        Else
            Worksheets("Calculations").Range("H33").Value = "No"
        End If



End Sub

This code won't even run, I get a compile error every time I try to run it. I'm new to VBA and know this is probably super easy but I just can't seem to get it.

Aucun commentaire:

Enregistrer un commentaire