if_and_or_then loop help

mswantek

Board Regular
Joined
Jul 9, 2002
Messages
123
I am trying to add some logic to a particular project I am working on. The form collects data basaed on a users input and then makes decisions based on certain criteria.
I am having some trouble getting a If (condition) and (condition) and (condition) then loop to give me my result. I feel that I am so close but am missing something pretty obvious.
Somebody please help.
The code is reading a excel database for a "true" or "false" input in a series of cells. If all the conditions are fullfilled, it routes the form to a particular user. The problem I am having when I step through the code is that the "and values" are all reading ok, but the "then" result is not tripping the value it should.
Sorry this is so long but I just want people to understand the problem.
code:
Code:
ElseIf Range("d9").Value = "Fabricate F/G Wheel covers" And _
'((ActiveCell.Offset(0, 20) = "TRUE" Or _
'ActiveCell.Offset(0, 112) = "TRUE") And _
'(ActiveCell.Offset(0, 27) = "TRUE" Or _
'ActiveCell.Offset(0, 114) = "TRUE") And _
'(ActiveCell.Offset(0, 34) = "TRUE" Or _
'ActiveCell.Offset(0, 116) = "TRUE") And _
'(ActiveCell.Offset(0, 41) = "TRUE" Or _
'ActiveCell.Offset(0, 118) = "TRUE") And _
'(ActiveCell.Offset(0, 48) = "TRUE" Or _
'ActiveCell.Offset(0, 120) = "TRUE") And _
'(ActiveCell.Offset(0, 55) = "TRUE" Or _
'ActiveCell.Offset(0, 122) = "TRUE") And _
'(ActiveCell.Offset(0, 62) = "TRUE" Or _
'ActiveCell.Offset(0, 124) = "TRUE") And _
'(ActiveCell.Offset(0, 83) = "TRUE" Or _
'ActiveCell.Offset(0, 130) = "TRUE")) Then
'checked = True
'Exit Sub
If anyone can help I would appreciate it.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
It will skip the THEN if the overall test is false - did you try evaluating each of your conditions to see what they each come out to?
 
Upvote 0
I see. Now when stepping through the entire and loop highlites, each individual case looks like it is satisfied so what would cause the whole case to fail if the individual parts don't?
 
Upvote 0
You have a lot of "ANDed" tests that would have to all be true... did you use shift F9 on each one to see what it evaluated to? If they all come out true, then I'm not sure what to suggest.
 
Upvote 0
earlyd,

The procedure is being called from another, and I have verified the active cell is what I want. That is what is so frustrating about this I guess. Thanks everyone for helping!!!!!

As I eluded to I have verified the results of the test and they come out.
What I have begun to do now is remove the paranthesis and it seems like it will do the trick. I will post soon and let all know.

Mike
 
Upvote 0
For all that care it WAS the parenthesis around the and or statements that caused it to not change the value called by the "then" statement. Thanks for all the other great ideas!!!!! I will incorporate them into the next release of my "program"!!!!

:biggrin: :biggrin: :biggrin:

This issue can now be closed!!!!

Thanks.

Mike
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,280
Members
449,220
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top