View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Worksheet Change Event

You almost had it on your own in your response to Don's reply earlier.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then MLV_wildcard_cell
... some code here
Exit Sub ' to keep from testing for E1 which didn't happen
End If

If Target.Address = "$E$1" Then ERM_wildcard_cell
... your code for a change in E1 here
End If
End Sub

Note that Target.Address returns the string representation of the address,
complete with the absolute indicators (dollar signs).

Hope this helps.

"Tony S." wrote:

Hi Mike, Thanks for your reply.
Perhaps I was unclear with my first post. My apologies. I want to run 2
different macros depending on the value entered in each cell. "A1" would run
Macro1 and E1 would run Macro2. Hope this clears things up.

"Mike H" wrote:

Maybe this

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1,E1")) Is Nothing Then
MsgBox "You changed " & Target.Address
' Display a message when one of the designated cells has been
' changed.
' Place your code here.
End If
End Sub

Mike

"Tony S." wrote:

I thare any way to execute more than one worksheet change per worksheet; say
for cells "A1" and "E1"?

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") 'another code for cell E1??

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.

End If
End Sub