excelguy
excelguy

Reputation: 1624

VBA, Skip Cell If

I want to loop through my range and incorporate the logic that if B2:B100 is "No" then skip.

Original code:

 Dim cell As Range
    For Each cell In Range("A2:A100")
        FilePaths.Add cell.Value
    Next cell

Trying:

If cell.Range("B2:B100") <> "Yes" Then

Not sure on where to go next. I want to go to next cell in col A, or continue back into col A.

Upvotes: 1

Views: 358

Answers (1)

DisplayName
DisplayName

Reputation: 13386

use Offset to point to a Range at given rows and/or columns offsets from referenced one

Dim cell As Range
For Each cell In Range("A2:A100")
    If cell.Offset(0, 1).Value2 <> "NO" Then FilePaths.Add cell.Value2
Next cell

Upvotes: 7

Related Questions