[Solved] need correction to my code

bigme

Member
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("C11")) Is Nothing Then
Range("C15") = Range("C11") * Range("D15")
Range("C19") = Range("C11") * Range("D19")
Range("C20") = Range("C11") * Range("D20")

Range("C12") = Range("C13") + Range("C14") + Range("C15")
Range("C16") = Range("C11") - Range("C12")
Range("C16") = Range("C18") + Range("C19") + Range("C20")
Range("C21") = Range("C16") - Range("C16")
End If
End Sub

i try this code, to do calculation every time the value in cells C11 changes, but in actual the calculation doesn't run, kindly help.

thank you & regards,
bigMe
 
Greetings,
Do you meant that the values in C12,C15 etc is not changing when you changes theother static value like the D15,D19,D20 etc?. I my case i have put the code in the Sheet and it worked perfectly, there might be one reason why your code didnot run. The reason might be that you didnot put the code in the sheet. I will demonstrate that in the following images.
Step 1. Open your sheet and right click on the Sheet1, and then from the context menu, click on the View Code.
1680070425059.png
Step 2:
Then in the code window, paste your code and hit the Save icon.
1680070536602.png
Step 3: Put some random values in the statice cells and then change the value in Cell11. You will notice that the cell values are changing.
When C11 value is 20, then other values are also changing.
1680070681195.png
Step 3: Switch the value to 15, and notice the value are also changed.
1680070803906.png
 

Attachments

  • 1680070516154.png
    1680070516154.png
    53.9 KB · Views: 0
  • Book1.xlsm
    14.1 KB · Views: 1
thank you very much for the explanation, now it's works... (y)
need one more explanation, if the value changes not directly do in the cells, for example using goal seek why it don't work? is a modification needed in the code?

best regards,
bigMe
 
thank you very much for the explanation, now it's works... (y)
need one more explanation, if the value changes not directly do in the cells, for example using goal seek why it don't work? is a modification needed in the code?

best regards,
bigMe
Greetings,
Its not actually clear what you meant. In this example you have multiple static value cell and some connected cells. Now if you changes the values of the statice cells, then other connected cell value will change. Goal seek totally a different topic in context to your given problem. IT would be better if you eleborate your problem with an example workbook. Additionally goal seek is not possible with multiple output, as shown in the below image. So it is unlikely that your problem will work in the goal seek context. It will be better if you add any sample file.
1680162695448.png
 

Online statistics

Members online
0
Guests online
18
Total visitors
18

Forum statistics

Threads
292
Messages
1,268
Members
531
Latest member
lonkfps
Top