View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default worksheet change event doesn't work

You don't want to change the procedu
Private Sub Worksheet_Change(ByVal Target As Range)

But you can check to see if the range Attn was in the range that got changed.
(Attn is a range name on that sheet???)

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myCell As Range
Dim myIntersect As Range

Set myIntersect = Nothing
On Error Resume Next
Set myIntersect = Intersect(Target, Me.Range("attn"))
On Error GoTo 0

If myIntersect Is Nothing Then
'not in there
Exit Sub
End If

For Each myCell In myIntersect.Cells
MsgBox myCell.Address
Next myCell

End Sub





gig wrote:

I have the following simple code for example reasons. For some reason,
when the range "attn" is changed, the macro won't operate.

Here is the simple code I have:

Private Sub Worksheet_Change(ByVal attn As Excel.Range)

Application.EnableEvents = False

MsgBox "hello"

Application.EnableEvents = True

End Sub

There is code to be inserted where the msgbox is. Any suggestions are
greatly appreciated.

Thank you,
Greg


--

Dave Peterson