+ Reply to Thread
Results 1 to 11 of 11

Unexpected SelectionChange event code

  1. #1
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145

    Unexpected SelectionChange event code

    Hello,
    time-to-time an unexpected eventcode appears in my worksheet modules
    Please Login or Register  to view this content.
    This leads to "macro confirmation dialog" on start of that worksheet.

    I know I can prevent from that dialog by deleting those events from all modules, but how can I avoid their very creating? When could they have appeared?

    Thanks a lot!

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Have you double-clicked on the sheet in the Prperties Window of the VB Editor?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145
    Probably, I did not.
    This usually starts like this:

    1) I get the "macro confirming dialog" in worksheet opened.
    2) I open the VB editor and go throug the sheet's source codes. In most of them (if not all) there is that empty event code.
    3) I delete them from each sheet.
    4) I'm confused.

    These workbooks are used by my colleagues too, but I doubt they doubleclick on anything in VB editor.

    BTW, I'm not sure what colud I doubleclick on in the Properties Window. You meen the name of the sheet in the dropdown menu? I don't see any results of that in related source code.

    Thank you for helping.

    PS: In my first post I probably misused the "module" term. I meant the sheet source code - You probably know...

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you open thge sheet code module that procedure is inserted automatically.

  5. #5
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145
    Maybe I'm missing something simple, but I can't reconstruct your example.
    1) I create a new workbook (Book6.xls).
    2) I open VB editor.
    3) I doble click the sheet1 module (Project explorer/VBAproject(Book6.xls)/Microsoft Excel Objects/Sheet1(Sheet1)
    4) I don't see any proceudre inserted.
    5) I save, close and reopen the workbook.
    6) Still don't see any unexpected codes nor am I getting any macro dialog.
    Is that what you meant?
    Many thanks.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try selecting WorkSheet in the left hand drop down after clicking on the sheet in the VBE

  7. #7
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145
    Nothing happens.
    There is only one option in the drop down menu:

    "Sheet1 Worksheet"

    After clicking the menu this option is offered to be selected. I select it and nothing visible hapens. No source generated.

    But even if it was, is this the only way, how the code can appear? I'd expected something less sophisticated, like unintentional adding (and removing) some control. But not explicit adding those object, we don't use them.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    I think Roy is referring to the left hand dropdown at the top of the Sheet Code window.
    The 2 dropdowns are for Objects and Procedures.
    If you select the Worksheet Object the stub for the Worksheet_Selection is automatically inserted.
    Cheers
    Andy
    www.andypope.info

  9. #9
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145
    I see, this worked!
    But I can not imagine, how could this happen unintentionally on more sheets in the workbook as I wasn't able to do it trying to.

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    I have never heard of code just appearing so somebody must be doing something, even if they are not aware of the implications.

    To stop users accidently wandering in to the code area you could lock the vb project for viewing.

  11. #11
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145
    I agree,
    somebody has to do something. It's just weird. I thought, this could be a known problem. Locking the vb project for viewing is a good idea.
    Roy, Andy, thank you a lot.
    Bristly

+ 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