Hi,
Hoping someone might be able to improve my code! I've got a bit of code that works, but is clearly very inefficient:
For UserTypeA = 0 To Total_Users
For UserTypeB = 0 To Total_Users
For UserTypeC = 0 To Total_Users
If UserTypeA + UserTypeB + UserTypeC = Total_Users Then
'do something
End If
Next UserTypeC
Next UserTypeB
Next UserTypeA
Effectively it's creating all the different combinations for a given number of user based on 3 different types.
This works but is very slow at high number of users as most of the looping is unnecessary as doesn't add up to total number of users.
Any suggestions?
Thanks, Wook
Hoping someone might be able to improve my code! I've got a bit of code that works, but is clearly very inefficient:
For UserTypeA = 0 To Total_Users
For UserTypeB = 0 To Total_Users
For UserTypeC = 0 To Total_Users
If UserTypeA + UserTypeB + UserTypeC = Total_Users Then
'do something
End If
Next UserTypeC
Next UserTypeB
Next UserTypeA
Effectively it's creating all the different combinations for a given number of user based on 3 different types.
This works but is very slow at high number of users as most of the looping is unnecessary as doesn't add up to total number of users.
Any suggestions?
Thanks, Wook
Last edited: