Both codes will run automatically when you change either B6 or B7
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).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).
Why don't you want to put the code in the sheet module?
No it's fine, i'm just trying to learn and i'm wondering if it's the same thing.
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....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.