Hi all,
Having trouble getting a bit of code to do what I want.
Basically I'm looking for a way of testing for a particular string in a cell then, if found, test n number of cells underneath that cell for the same string. If they ALL contain the same string THEN do the rest of my code. At any point when testing for the string, if its NO then skip to the Next Cell (makes more sense when you look at my code I think because I've not explained the For Each Cell).
I came up with that which combines a few bits from other questions I've asked in the past (if you're one of those folks then thanks!) and yeah, I know its a mess at the moment lol - but I was trying to bodge it a little before tidying it up.
I'll post any additional tidier methods I try in the meantime
Thanks all!
Having trouble getting a bit of code to do what I want.
Basically I'm looking for a way of testing for a particular string in a cell then, if found, test n number of cells underneath that cell for the same string. If they ALL contain the same string THEN do the rest of my code. At any point when testing for the string, if its NO then skip to the Next Cell (makes more sense when you look at my code I think because I've not explained the For Each Cell).
VBA Code:
For Each cell In Range(Cells(searchRow, 3), Cells(searchRow, lastCol))
If cell.Value = "yes" Then
For Y = 1 To tSlots
If cell.Offset(Y, 0).Value <> "yes" Then
GoTo NextCell
ElseIf cell.Offset(Y, 0).Value = "yes" Then
If Y = tSlots Then
s = s & "," & cell.Address 'this is the part I'm referring to as "The rest of my code" - this is the part that runs if all Y.value = "yes"
ElseIf Y <> tSlots Then GoTo NextY
End If
End If
NextY:
Next Y
End If
NextCell:
Next cell
I came up with that which combines a few bits from other questions I've asked in the past (if you're one of those folks then thanks!) and yeah, I know its a mess at the moment lol - but I was trying to bodge it a little before tidying it up.
I'll post any additional tidier methods I try in the meantime
Thanks all!