View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Conditional "If Not ... Then" Statement not working properly H

Here is a different way to track your "true" conditions...

Sub Test()
Dim Count As Long
Dim TestCondition As String
TestCondition = String(3, "X") & " "
For Count = 1 To 4
MsgBox "Count #" & Count
MsgBox "Number of 'True' conditions is " & _
Len(Replace(TestCondition, " ", ""))
Mid(TestCondition, Count) = " "
Next Count
End Sub

--
Rick (MVP - Excel)


"Dan Thompson" wrote in message
...
Hey JLGWhiz
This is what I am trying to accomplish only I would like to do it in the
shortest amount of code as possible. I think my code is a little long for
this macro. here is the code

Sub test()
Dim one As Boolean, two As Boolean, three As Boolean
Dim Count As Integer
one = True
two = True
three = True


For Count = 1 To 4
If Count = 1 Then one = False
If Count = 2 Then two = False
If Count = 3 Then three = False
MsgBox "Count # " & Count
If one = False Or two = False Or three = False Then
MsgBox "One or more of the 3 conditions are false"
End If
If one And two And three = True Then
MsgBox "All of the 3 conditions are true"
End If
one = True
two = True
three = True
Next Count
End Sub


"JLGWhiz" wrote:

Also:

If Not one = True Or Not two = True Or Not three = False Then
MsgBox "One or more of the 3 conditions are false"
End If



"Dan Thompson" wrote in message
...
The following code should pop up a message box but it is not doing so
where
am I going wrong ?


Sub test()
Dim one As Boolean, two As Boolean, three As Boolean
one = True
two = True
three = False

If Not one = True And Not two = True And Not three = False Then
MsgBox "One or more of the 3 conditions are false"
End If
End Sub

Dan Thompson