Possible to run a small macro every time I change a value in a cell?

  • Thread starter Thread starter Christian Borchgrevink-Lund
  • Start date Start date
Christian,

You can use the Change event to do this. In the code module for
the appropriate worksheet, use code like the following. Change
the cell address to the cell you need.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$3" Then '<<< Change to cell address
' your code here
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
OK, but where is the code module? How do I put in a lot of different celles
or a range of cells?

Thanks

Christian
 
Christian,

Right-click on the sheet tab and choose View Code to open the
code module associated with the worksheet. To use a range of
cells, write code like

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1:C10"), Target) Is
Nothing Then
' do something
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top