Start VBA macro when a cell gets value

EDSDaniel

New Member
Joined
Nov 3, 2005
Messages
9
hello

Is there any way to make a VBA macro start when a certain cell gets a value?
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
Look at the Worksheet Change Event ie:

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' Only look at single cell changes
If Target.Count > 1 Then Exit Sub

'Only look at cell changes in your defined range (ie Range A1:A10)
If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
    If Target = "" Then Exit Sub    'If Cell is blank, Ignore
    'If Cell has value you require - Call Macro
    If Target = 1 Then
        Call YourMacroNameHere
        Exit Sub
    Else
    End If
End If
End Sub

Worksheet Change code to be placed in the worksheet you wish to check

The macro you wish to call should be in a standard module.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,081
Messages
5,570,088
Members
412,310
Latest member
mark884
Top