I have hard-coded for ever two cells in an excel column to count if either the first or second have a value of 1. It worked this way (but also written out for every cell applicable so is inefficent):
If Range("D10").Value = 1 Or Range("D11").Value = 1 Then
x = x + 1
Else
x = x + 0
End If
I am trying to refactor it. My thought was to do a for loop, with an if and an or statement (similar to in my current code), but receive a syntax error. My attempt:
Sub refactor()
Dim x As Integer
x = 0
For Each c In Range("D2-D13").Cells
If c.Value =1 OR (c+1).Value = 1 Then
x = x + 1
Else
x = x + 0
End If
Range("A19") = x
End Sub
All I can find is for loops with if statements in them, but never the added "or" condition considered. VBA is new to me. Is there a way I can code this?