ciao a tutti!!
Ho un foglio excel che si aggiorna automaticamente e ad ogni aggiornamento avrei bisogno che facesse alcuni calcoli in automatico. Sono riuscito a far funzionare la
cosa tramite l'evento OnClick
di un pulsante, adesso vorrei applicarlo all'Onchange di una particolare
cella ma non so come si chiama l'evento, potete aiutarmi?
Questo è il mio programma.
Private Sub CommandButton1_Click()
Dim acquisto As Double
Dim vendita As Double
Dim acquisto_old As Double
Dim vendita_old As Double
Dim volume As Double
Dim prezzo As Double
Dim volume_acq_old As Double
Dim volume_ven_old As Double
prezzo = Cells(2, "c")
volume = Cells(2, "e")
acquisto = Cells(4, "b")
vendita = Cells(4, "e")
acquisto_old = Cells(13, "b")
vendita_old = Cells(14, "b")
If ((acquisto <> acquisto_old) Or (vendita <> vendita_old)) Then
If prezzo = acquisto Then
Range("a20") = Cells(17, "a")
Range("c20") = Cells(17, "c")
Range("a17") = 0 + volume
Range("c17") = 0
End If
If prezzo = vendita Then
Range("a20") = Cells(17, "a")
Range("c20") = Cells(17, "c")
Range("c17") = 0 + volume
Range("a17") = 0
End If
Else
If prezzo = acquisto Then
Range("a17") = Cells(17, "a") + volume
End If
If prezzo = vendita Then
Range("c17") = Cells(17, "c") + volume
End If
End If
acquisto_old = acquisto
vendita_old = vendita
Range("b13") = acquisto_old
Range("b14") = vendita_old
End Sub
grazie