Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running macro when updating a cell 1

Status
Not open for further replies.

BoFenger

Programmer
Aug 6, 2003
22
DK
Hi TT
I'am using VBA under excel
Is it possible to run a macro when a normal cell is changed, fx. from 6 to 15

\Bo
 
You can do this by using the Change event of a worksheet. If you want to specify a particular cell, check if the "TARGET" cell is the correct cell.
 
An example

Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range

' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("A1:C10")

If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then

' Display a message when one of the designated cells has been
' changed.
' Place your code here.
MsgBox "Cell " & Target.Address & " has changed."

End If
End Sub

HTH

Chris ;-)

Visit for great xl and xl/VBA help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top