2 cells always sum to same value

jkicker

Board Regular
Joined
Jun 7, 2018
Messages
79
Where would i put this information so that i can change b6 OR b7 and the other would change itself:
b6 = 600-b7
b7 = 600-b6

I want the cells to always sum to 600 but be able to change their values individually.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Yes but why? like i said normally you have to execute macros manually.
They are not macros... they are event code (which is why they are installed into a different module than macros)... macros need to be run manually, event code runs automatically in reaction to some event (in your case, that event is the changing of a value in the Target range).
 
Upvote 0
They are not macros... they are event code (which is why they are installed into a different module than macros)... macros need to be run manually, event code runs automatically in reaction to some event (in your case, that event is the changing of a value in the Target range).

instead of right clicking on the sheet tab, could i add a class module in the VBA window?
 
Upvote 0
Why don't you want to put the code in the sheet module?
 
Upvote 0
No it's fine, i'm just trying to learn and i'm wondering if it's the same thing.

oh I understand. now i see they go in different places. so if i write code into an object will it automatically be event code? and if i put it in a module it'll be a macro? or does it depend on what kind of module i use?
 
Upvote 0
...so if i write code into an object will it automatically be event code?
No, event code requires the procedure header (the Sub line of code) to be constructed in a specific way for each event. You don't have to learn them, though, as the VB editor supplies them for you. To see this, right click a worksheet tab to bring up the code module for that sheet (it doesn't matter which sheet because we are not going to actually code anything). After you do that, look at the top of the code window... you will see two drop downs... click the one that says "General" and select "Worksheet". Now, after doing that, if you click the other drop down, it will show you all of the events available for the worksheet. Clicking any one of the events in that drop down will place the proper header (and closing End Sub) into the code window. If you do that for a few of the events, you will see how the procedure header varies for each one (some might not vary, others will vary considerably). All the programmer has to do after placing the event code header/footer is write the code for that event inside of it. VBA takes care of running the event code automatically when that event is evoked.
 
Upvote 0
No, event code requires the procedure header (the Sub line of code) to be constructed in a specific way for each event. You don't have to learn them, though, as the VB editor supplies them for you. To see this, right click a worksheet tab to bring up the code module for that sheet (it doesn't matter which sheet because we are not going to actually code anything). After you do that, look at the top of the code window... you will see two drop downs... click the one that says "General" and select "Worksheet". Now, after doing that, if you click the other drop down, it will show you all of the events available for the worksheet. Clicking any one of the events in that drop down will place the proper header (and closing End Sub) into the code window. If you do that for a few of the events, you will see how the procedure header varies for each one (some might not vary, others will vary considerably). All the programmer has to do after placing the event code header/footer is write the code for that event inside of it. VBA takes care of running the event code automatically when that event is evoked.

whoaa cool! ok so i thought the words next to sub were the title of the sub, and if that continues to be true then the text in the brackets is what makes it event code?
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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