+ Reply to Thread
Results 1 to 8 of 8

Worksheet_Change event not working on xl2003

  1. #1
    Forum Contributor
    Join Date
    06-07-2008
    Posts
    126

    Worksheet_Change event not working on xl2003

    I have a simple Worksheet_Change code which works fine on my computers but is not working on another persons computer. When a change is detected the code runs but some of the variables appear to be 'empty' when he runs it.

    I tried it on Excel 2000 and 2008. The other person has Excel 2003.

    Why would it run on one computer but not run on another.

    Any ideas?

  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,259
    Hello matrex,

    If you post the workbook, I can review the code and run it on both 2000 and 2003 to isolate the problem.

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    06-02-2005
    Location
    India
    MS-Off Ver
    2007
    Posts
    138
    May be the other person may have not enabled the macros.

  4. #4
    Forum Contributor
    Join Date
    06-07-2008
    Posts
    126
    Ok, here is the code in the Worksheet code area:
    What it is supposed to do is check if the entered value already exists in the listin C3:C7.
    And yes macro security is set to "Low" since the code does start but the variables (xval or xval1) are not read correctly!


    Please Login or Register  to view this content.

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

    You don't disable/re-enable Events in your code. This is necessary when using either the Worksheet_SelectionChange or Worksheet_Change events to prevent the event from being retriggered and causing strange behaviors or evening crashing Excel. Here is how the code should be structured to prevent problems.

    Standard VBA Module Code
    Please Login or Register  to view this content.
    Worksheet Event Code
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Quote Originally Posted by matrex
    And yes macro security is set to "Low" ...
    That is a disaster in the making.

    Never set Macro Security to less than Medium.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    If I understand what you're doing, you just want to avoid duplicates in the range C3:C7. If that's correct, you can do all this pretty easily in the Change event. And in this particular case, there's no need to disable events.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-07-2008
    Posts
    126
    Thanks Leith for you advice.

    Yes I do use the Application.EnableEvents when necessary to stop the change detection while the macro is executing, but in this case this is not the issue as the change event does execute.

    The problem is almost defintely in the xval variable in this line
    xval = Cells(r_row, c_col)
    which is not getting any values and seems to stay 'empty'

    But only when run by that user. And this is the puzzling part.

    Thanks again Leith for you insights.

    matrex.

+ 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