Home > Software engineering >  To excelVBA cycle calculation for the optimal combination of the program code
To excelVBA cycle calculation for the optimal combination of the program code

Time:09-16

To do a data model, there are two variables, x and y, x plan duty salary for the month, y as the year-end bonuses, now want to y (award) m times according to certain proportion n split into x; The way according to the monthly salary tax and year-end bonus tax tax a and b are calculated respectively; A plan tax basis for x + y) n, b plan tax basis for y x (1 - n),
N known from 0% ~ 100%, and step length is 0.1%; 0Different x and y correspond to the calculation results of return to the attached "results in the table,"

Ps: you need to use VBA to write calculation rules, and then set a variable cycle calculation, a great god help, thank you very much!!!!!!

The attachment link:
https://pan.baidu.com/s/1F3gP_Udpz_PE7rtXxozK7A

CodePudding user response:

This kind of problem, generally by middle school knowledge, calculation function parameter values within the scope of function value of extremum can, in the draft paper work it out faster than you could write code
Even to coding solution, iterate over all n may then output the minimum also just, your demand is a 1000 - cycle, for now the computer you haven't come even if done, and don't be too mind cycles,
If you have now met with difficulty with VBA code can use excel formula to solve, first write the first formula, set up n, and then use the excel own rapid filling generated 1000 lines of different n data, then choose the result column inserts a line chart, instantly know where low

CodePudding user response:

Look not to understand, a and b are two calculation, so the final tax is how to calculate?
Tax=a * 12 + b?
  •  Tags:  
  • VBA
  • Related