Execute macro on cell value change

  • My first post! Let's see how it goes :p...
    I'm quite new on VBA althought I've been making some things in Excell. I have several columns which show the different prices a product (rows) is sold, but I also want those columns to be able to register values (quantity of units needed).
    I've thought of a funtion which checks the other price columns of the row. If the values are 1, 2, 3 etc they should be set back to the price if the selected cell has been changed to 1, 2 or 3...


    I'm more used to JavaScript, where there is the OnChange command. Has VBA something like that?
    Thank's very much in advance ;)

  • Ok, an example...
    Let's say I have a table like this:


    Code
    1. [B]Product Shop1 Shop2 Shop3[/B]
    2. Something 19.50€ 18.00€ 23.99€
    3. Otherthing 4.99€ 6.50€ 4.50€


    I want to make something like a shopping list with this. If I want to buy 3 units of 'Something' at 'Shop2' and 1 of 'Otherthing' at 'Shop3' I will change the table to something like this:


    Code
    1. [B]Product Shop1 Shop2 Shop3[/B]
    2. Something 19.50€ 3 23.99€
    3. Otherthing 4.99€ 6.50€ 1


    But what if I change my mind? What if I now want to buy 3 units of 'Something' not to 'Shop2', but to 'Shop1'? I want to just have to write '3' in the 'Shop1'/'Something' cell and the original price of 'Shop2' should appear automatically when the value changes:


    Code
    1. [B]Product Shop1 Shop2 Shop3[/B]
    2. Something [COLOR=YellowGreen]3[/COLOR] [COLOR=SandyBrown]18.00€[/COLOR] 23.99€
    3. Otherthing 4.99€ 6.50€ 1


    Written by me Changed by program


    I think it would be easy to make a macro which checks for the values of the other Shops cells and makes the necessary changes, but I need something which executes it. In JavaScript there's the OnChange command, so I thought of something similar in VBA.


    I hope I explained myself better now...


    It seems Worksheet_Change is what I'm looking for, but I'm open to suggestions... :)