-2

I have a very huge while wend loop in my Excel VBA.

Earlier in the code I set a variable strMode to True or False.

If it is False then in my while condition I want to set

while var1 + var1previous > 1 

and if it is True

while var1 + var1previous > 1 or var1previous+ var1  > 1

How can I do that, if I don't what to "double" the While-Wend code, for my If statement?

Community
  • 1
  • 1
H_Tens
  • 1
  • 2

1 Answers1

0

I'm going to guess what you are trying to do because just like @Gserg mentioned,

your second condition looks the same.


I am going to call var1+var1previous>1 condition Cond_A and second condition which you used after or Cond_B

Cond_A = var1+var1previous ' This will be first condition
Cond_B = 0
If strMode then Cond_B = var1+var1previouis 'This will be second condition

While Cond_A > 1 or Cond_B > 1   

What I did above is that when strMode value is true then you are comparing both of conditions.

When strmode is false, then since the second condition already set to false

and because of or it will just compare Cond_A and loop.

MutjayLee
  • 578
  • 3
  • 6
  • Thx MutjayLee - var1 and var1previous are changed during the while wend loop, I guess my problem is I don't know how to declare the variable Cond_A and B so that they are read the right way in the while condition. :-/ – H_Tens Jun 05 '16 at 13:47
  • MutjayLee - you just gave me an idea there - I can introduce a 0/1 variable and multiply the condition (B) condition to 0 or 1 accordingly and that Works - thx Again - can I give some kind of points ? – H_Tens Jun 05 '16 at 14:49
  • I don't really care about the points. I don't even know what the points are for. I just like helping people solve their problem. And I know I did not solve directly, but I'm glad I could be assist to your problem :) – MutjayLee Jun 05 '16 at 18:07