Hi all,
I'm using an IF statement to merge cells matching cells in a column - gotta make stuff pretty after all /s
Anyway, my code looks like this
Which works fine.
However, I would like to add a second condition after the And - so there would basically be two things to ignore; the first being blanks and the second being "stringystring"
trying this code just causes the code to loop indefinitely and excel stops responding. I think this is something to do with me using "<>" twice. I've used it in the first example to say "cell value doesn't equal blank" but I think I'm misusing it where I should be using a Not operator?
Thanks
I'm using an IF statement to merge cells matching cells in a column - gotta make stuff pretty after all /s
Anyway, my code looks like this
VBA Code:
Application.DisplayAlerts = False
Recheck:
For Each cell In Range("C4:C148", Range("C4").End(xlToRight))
If cell.Value = cell.Offset(1, 0) And cell.Value <> "" Then
Range(cell, cell.Offset(1, 0)).Merge
GoTo Recheck
End If
Next
Application.DisplayAlerts = False
Which works fine.
However, I would like to add a second condition after the And - so there would basically be two things to ignore; the first being blanks and the second being "stringystring"
VBA Code:
Application.DisplayAlerts = False
Recheck:
For Each cell In Range("C4:C148", Range("C4").End(xlToRight))
If cell.Value = cell.Offset(1, 0) And (cell.Value <> "" Or cell.Value <> "stringystring") Then
Range(cell, cell.Offset(1, 0)).Merge
GoTo Recheck
End If
Next
Application.DisplayAlerts = False
trying this code just causes the code to loop indefinitely and excel stops responding. I think this is something to do with me using "<>" twice. I've used it in the first example to say "cell value doesn't equal blank" but I think I'm misusing it where I should be using a Not operator?
Thanks