View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default "Or" statement not working

I would stay within the macro but if you insist on doing that why not one
cell
if(a=a,1,0)+if(b=b,1,0)
then
if range("a2")<3 then msgbox "bad boy"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Chris T-M" wrote in message
...
Thank You, that does appear to work.

Another solution I came up with was to simply add an "IF(OR..." function,
in
a variables area, that provides a Yes/No output. I then changed the "If"
statement in my code to look only at that cell. (If Range("BZ28").Value =
"NO" _)

Now I need to decide which will make more sense to me when I try to edit
this in 6 months.

Thanks again,
Christopher McCune

"Don Guillett" wrote:

I just tested this and it worked fine. Perhaps you don't want = but do
want
< (NOT equal)

Sub checkit()
If Range("h8").Value = "F" Or _
Range("h6").Value = Range("h7").Value Or _
Range("h4").Value = Range("H2").Value _
Then
MsgBox "dont do it"
Exit Sub
Else
MsgBox "doit"
'Do macro.
End If

End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Chris T-M" wrote in message
...
If any of these conditions exist, then I want the message. Only if all
are
met do I want to continue the macro. I believe that means I need an
"or"
function.

"Don Guillett" wrote:

Do you want AND instead of OR?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Chris T-M" wrote in message
...
This Macro excerpt is based on a "Check Cell Content before
continuing..."
discussion with Bill Renaud back in October.

I works great (thanks Bill) with one exception.

If the cells are changed in reverse order of my "Or" statements
(Conditions
3, & 2 are met first) then the Macro continues even though the 1st
condition
has not been met.

Every other combination works.

Thanks in advance for any help on this. (Code Below)

'/// Check for Required Fields (Project Number)
If Range("Q44").Value = "Fill in..." Or _
Range("F47").Value = Range("AB2").Value Or _
Range("H56").Value = Range("AH2").Value _
Then
MsgBox "Please fill in the Abbreviation, Project Type, Class, and
Application Date fields (blue font with an *)", _
vbCritical + vbOKOnly, _
"You have not filled in all the fields required to
generate a
complete project number."
Exit Sub
Else
'Do macro.
End If