+ Reply to Thread
Results 1 to 5 of 5

Trigger worksheet_change

  1. #1
    Forum Contributor
    Join Date
    03-09-2004
    Posts
    140

    Trigger worksheet_change

    Hi there
    This problem is headach

    In sheet2 A1 i put this formula = sheet1 A1

    so whenever i type a value in sheet1 A1, then it will appear in the sheet2 A1.........through the formula in (=sheet1!A1) which is placed in sheet2 A1

    i put a private worksheet_change in sheet2
    my problem is that the private worksheet_change is not triggered when the value of A1 in sheet2 changed

    How to trigger a private code when results appear through built-in formulas or functions ?
    I know that This event occurs when the value of a cell is changed. This event does not occur when the value is changed as the result of a calculation.

    Is there any why around it to trigger the event ?
    Last edited by helmekki; 02-17-2005 at 08:41 AM.
    Yours
    hesham Almakki
    http://www.almakki.com.ly/

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Helmekki,

    The event that is triggered by the code is

    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

    End Sub



    You can add the following code to this event to monitor cell A2

    If Target.Address = "A2" Then
    <execute your code>
    End If

    _________________________________________________________________

    Hope this helps,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    03-09-2004
    Posts
    140
    Thank u very much 4 your reply ,Leith Ross

    but the private code was not triggered even when i put your code
    Please Login or Register  to view this content.
    any ideaa why

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Helmekki,

    If I understand correctly, the code is simply updating the cell on worksheet 2 when cell value of worksheet 1 changes.

    Add this code to the worksheet 1's Private Sub Worksheet_SelectionChange Event
    _________________________________________________________________


    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

    If Target.Address = "$A$1" Then
    Worksheets("Sheet2").Range("A1").Value = Target.Value
    End If

    End Sub

    _________________________________________________________________

    This automatically updates cell A1 on sheet 2 when cell A1 on sheet 1 is selected by the user but not by code. Worksheet events are driven externally. There are no internal events that are exposed to the VBA environment. You may need to re-evaluate your program design. In code you can do want you want, when you want. You are freed from waiting for the user, unless you need to wait for some specific action or input from the user.


    Hope this helps,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    03-09-2004
    Posts
    140
    Thank u very much, Leith Ross

    It worked

+ 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