View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Bill Renaud Bill Renaud is offline
external usenet poster
 
Posts: 417
Default "Or" statement not working

<<OK you lost me.
Where did we lose you? (We are the ones that are lost!!! :) )

<<...the logic I used in the Macro works if used as a Function, so why
wouldn't it work in a Macro?
I think you have this backwards. In general, everything will work in a
macro, but will not necessarily work in a function. For example, you can
set other cells (run your macro after deciding that everything is OK),
insert new worksheets into the workbook, run other commands, but you can't
do those things if the function were called from a formula in a worksheet
cell.

<<What I meant to say was:
If any are true, then show message.
If all are false, then do macro.

Then the logic in your original post should work, as that is exactly what
it does. It will check all 3 conditions, and if ANY of the 3 are TRUE, then
it will display the MsgBox and exit. So, if Q44 has some other value in it
(i.e. "Project X"), but F47 is equal to AB2, then your macro will run (the
Else part of the If statement).

If Range("Q44").Value = "Fill in..." Or _
Range("F47").Value = Range("AB2").Value Or _
Range("H56").Value = Range("AH2").Value _
Then
MsgBox ...
Exit Sub
Else
'Do macro.
End If
--
Regards,
Bill Renaud