Need help: after processing a loop for getting the max value, how do we get the variants corresponding to the max value?

dylan32123

New Member
Joined
Dec 7, 2016
Messages
6
here is the detail of what am doing and what i want to achieve, thx a lot for your help!

[FONT=arial, courier new, courier, 宋体, monospace, Microsoft YaHei]dim a1 as variant
dim b1 as variant
dim a2 as variant
dim b2 as variant
dim c as variant
dim maxC as variant

for a1 = 0 to 250 step 5
for a2 = 0 to 250 step 5
b1 = calculation with a1
b2 = calculation with a2
if c > maxC then
maxC = c
end if
next a2
next a1

after using this loop how can we get the value of a1 & a2 when the maxC reached?

thx again
[/FONT]
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try this (not tested):
Code:
......
If c > maxC Then
    maxC = c
    maxC_a1 = a1
    maxC_a2 = a2
End If
......
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

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