Reputation: 483
How can I have a macro automatically run whenever a cell in my Excel spreadsheet is updated?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "A1" And Target.Value > 0 Then
MsgBox ("A1 has changed.")
Application.Run("A1Changed")
End If
End Sub
But that's only when the value becomes positive. How can I have this macro jump into action when ANY change is made to A1? Also, does using a Private Sub mean that this will constantly be monitoring my spreadsheet for updates?
My problem is to export data from excel to SQL Server when the cell is updated or changed.
Upvotes: 0
Views: 2351
Reputation: 61
Uhm, delete the part "And Target.Value > 0"
A VBA Private Sub can only be called from anywhere in the Module in which it resides.
Upvotes: 0