ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through valid inputs (VBA) (https://www.excelbanter.com/excel-programming/366764-looping-through-valid-inputs-vba.html)

[email protected]

Looping through valid inputs (VBA)
 
How to write a simple program to:


Test all possible combinations of adding two numbers that range from
1-100 each (10,000 total possible combination) using some sort of
looping structure.



My guess (and I'm new at programming) is that there will be some sort
of nested loops but the logic escapes me.


[email protected]

Looping through valid inputs (VBA)
 
Not sure what you want to test but

for N = 1 to 100
for M = 1 to 100
'perform test
next
next

will give you the loop structure you want.

wrote:
How to write a simple program to:


Test all possible combinations of adding two numbers that range from
1-100 each (10,000 total possible combination) using some sort of
looping structure.



My guess (and I'm new at programming) is that there will be some sort
of nested loops but the logic escapes me.



JLatham

Looping through valid inputs (VBA)
 
DS's solution is for those who don't trust the system.
Bob Phillips is for those with faith in something as well established as For
Next loops to actually work.

You could combine the two in your MsgBox output to compare the values
computed by each method.

"DesireeStar" wrote:

Heh, yeah. I mean to produce an actual number as to how many times it
looped total.

Ie:
MsgBox "This looped " + loopCountTotal + " times"




All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com