Event / Macro - variables to add up to a constant value by c

Cosmos75

Active Member
Joined
Feb 28, 2002
Messages
359
I want to make a macro or use excel event. I have 8 variables (x1 to x8) that I want to be able to add up to a constant value by changing one or even more then one but not the others.

E.g. (x1*1.1)+ (x2*1.2)+ (x3*1.3)+ (x4*1.4)+ (x5*1.5)+ (x6*1.6)+ (x7*1.7)+ (x8*1.8 )=120

I have the Variable (x1 to x8 ) listed in Column A and the multipliers (1.1 to 1.8 ) in Column B.

How can I change x1 have the other change appropriately? Or change a few variables and have the others change appropriately?

Each variable has a lower limit that they cannot go under and an upper limit that cannot go over. For example, x5 has to be between 5 and 40.

Also, each variable cannot be a negative number.

Is there I way I can do this?

If someone could get me started with
1) How the code to add, subtract, multiply, divide
2) What to look out for when changing several variables out of the eight
3) How to set the limits.
I've had some replies to this in the past but I don't know how to write code for events and my VBA code knowledge is limited to selecting ranges and copy/paste stuff.

FANTASY REQUEST:
One more request, although this certainly isn’t necessary. Is there anyway to add a scroll-bar to each variable, whereby if I move one scroll-bar, the others move accordingly? Just curious to see if it could be done. (A scroll-bar from the forms tool-box where you can link a cell to it and move the “scroller” or click the arrows on the scroll-bar to change the value in the cell in specified increments and with a lower and upper limit is what I mean.)

Note: That smiley face is 8 )
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,214,395
Messages
6,119,265
Members
448,881
Latest member
Faxgirl

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