VBA Code Worksheet_ Change

FIRSTCHOICE

Board Regular
Joined
Dec 14, 2011
Messages
93
Hey,

I am looking for some guidance on developing some code to do some worksheet change event code. I have a situation where I have 4 columns, (A,B,C,D). The values that are in these cells are all interconnected (you can find A with the value in D or value in C from the value in A). I am looking to create some code where I would only have to put one value in one of the cells and the other three on that row would compute. In addition, if they are all empty then it stops trying to compute and if there are values in them it stops.


I have decent VBA skills for a novice so if someone could help me get started I think I could manipulate it well.

Thanks,
HN
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi HN,

Yes, this is not hard to do with VBA, but obviously you must do the calculations/formulas in VBA rather than with worksheet functions.

You have to test for the column that has been edited in the Worksheet_Change event (the column is Target.Column) to determine whether it is A, B, C or D. Then disable events (Application.EnableEvents = False) to keep the output cell changes from causing the Worksheet_Change event from triggering recursively. Then calculate and set the values of the dependent column cells, then re-enable events (Application.EnableEvents = True).

Say the Target.Column = 4 (i.e., column D has changed) so now you want to calculate A in the same row as a function of the value of D. You would just set the A cell using

Cells(Target.Row,"A") = (the value)

Not so hard. I hope you find this helpful.

Damon
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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