Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel - Event does not fire?

Posted on 1998-04-01
2
Medium Priority
?
207 Views
Last Modified: 2008-02-01

The following code is supposed to execute whenever a selection change occurs (I assume that is when you move from one cell to another), however, it does not seem to work this way on my computer. (Excel 97)

Option Explicit

    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
         MsgBox("Selection change event")
    End Sub

Can anyone explain why this is so?
0
Comment
Question by:idek1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
frazer earned 160 total points
ID: 1612066
Hi,

The code is correct and works on my computer (excel 97).
Have you put the code into the worksheet or is it in a module?
If it is not in the worksheet you can do so by going to the VBA editor, selecting the required sheet, then change the word (general) at the top of the module to worksheet, this in turn will change (declarations) to SelectionChange.
That will produce the private sub for you then you just need to enter your code.  e.g.
MsgBox("Selection change event")

Hope this helps

Frazer

0
 

Author Comment

by:idek1
ID: 1612067
Thank you frazer,
Yes, my code was in a module, and putting it into the worksheet solved the problem.
However, i do not understand why the code needs to be in the worksheet rather than the module: everything else (VBA code including other events like button clicks etc.) is in a module.

Also is the SelectionChange event something that is new to Excel97? If so, is there a way to get similar behaviour in previous versions of Excel?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question