+ Reply to Thread
Results 1 to 4 of 4

worksheet change event doesn't work

  1. #1
    gig
    Guest

    worksheet change event doesn't work

    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


  2. #2
    Dave Peterson
    Guest

    Re: worksheet change event doesn't work

    You don't want to change the procedure:
    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

  3. #3
    gig
    Guest

    Re: worksheet change event doesn't work

    Yes, "attn" is the range name on the worksheet. When data is entered
    into the "attn" range, I want the macro to commence.

    Greg


  4. #4
    Bob Phillips
    Guest

    Re: worksheet change event doesn't work

    Private Sub Worksheet_Change(ByVal Target As Range)

    APplication.EnableEvents = False
    On Error Goto ws_exit:
    If Not Intersect(Target, Me.Range("attn")) Is Nothing Then
    myMacro
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "gig" <gigdive@aol.com> wrote in message
    news:1111327626.921014.49520@l41g2000cwc.googlegroups.com...
    > Yes, "attn" is the range name on the worksheet. When data is entered
    > into the "attn" range, I want the macro to commence.
    >
    > Greg
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1