Hi all,
This bit if code works perfectly
where string1 is found, that cell address is added to s. So far so good.
What I actually want to do is loop through a second if statement where n number of cells below the initial cell are checked which I thought would look like this
tSlots is a number determined elsewhere and is the number of cells that need to contain the string in order for the first cell.address to be added to s. I expect just the original cell address to be added to s rather than a range of cell addresses.
regardless, when tCheck does = tSlots, nothing is added to s like it should be and I'm not sure why.
Any help on this one?
Thanks all!
This bit if code works perfectly
VBA Code:
For Each cell In Range(Cells(searchRow, 3), Cells(searchRow, lastCol))
If cell.Value = string1 Then s = s & "," & cell.Address
Next cell
where string1 is found, that cell address is added to s. So far so good.
What I actually want to do is loop through a second if statement where n number of cells below the initial cell are checked which I thought would look like this
VBA Code:
For Each cell In Range(Cells(searchRow, 3), Cells(searchRow, lastCol))
If cell.Value = string1 Then
For Y = 1 To tSlots
If cell.Offset(Y, 0).Value = string1 Then
tCheck = tCheck + 1
End If
Next Y
End If
If tCheck = tSlots Then s = s & "," & cell.Address
Next cell
tSlots is a number determined elsewhere and is the number of cells that need to contain the string in order for the first cell.address to be added to s. I expect just the original cell address to be added to s rather than a range of cell addresses.
regardless, when tCheck does = tSlots, nothing is added to s like it should be and I'm not sure why.
Any help on this one?
Thanks all!