Event / Macro - variables to add up to a constant value by c
VBA Telemetry pings you when your VBA projects fail
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

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

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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 )

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Finally got an example of code as a starting point! Check out the link.

    http://www.mrexcel.com/board/viewtop...c=3782&forum=2

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com