Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Excel, run Code when cell selected.

Status
Not open for further replies.

Wally0

Programmer
Aug 6, 2001
9
US
I want to run code when the user selects (moves on to) a cell in Excel. I have tried testing the active cell to determine if it matches my criteria (cell) but have not found the proper syntax. I know this must be simple... Please excuse my stumble. Any help in directing me to a helpful message thread or hints would be greatly appreciated.

Thanks, Wally
 
I assume you've already figured out you need the Sheet_SelectionChange event. This event sub has a target parameter, which is a range. You can use a comparison such as

if target.address=range("MySpecialCell").address then
..do code here
end if

Rob
[flowerface]
 
I tried your solution and get an error message "object required." I'm wrong somewhere in setting up the Target.address. Another hint? Thanks for your quick reply and assistance.

Wally
 
It's working -- ignore the error. I tried to run my code from a sub routinue.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top