"If Not.." crashes
I have a macro which tells Excel to run through a list of cells
and print a worksheet if the content of the cell satisfies two
conditions. The first one is that the content of the cell should
match the content of a cell named "Restrict". This works.
The other condition is that the cell should not contain a question
mark. I can't get this to work. The macro works fine if I let it
look for a "?" and then print if it finds one - but I want the
opposite, cells with "?" in them should be ignored.
This is the code that works:
If Left(ActiveCell, Len(Range("Restrict"))) = Range("Restrict") _
Then
If InStr(1, ActiveCell, "?") Then
[Code for print-out]
End If
End If
I've tried to amend the second line like this:
If Not(InStr(1, ActiveCell, "?")) Then
and
If InStr(1, ActiveCell, "?") = 0 Then
but when I try to run the macro, Excel freezes up before
finishing.
What am I doing wrong here??
|