Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Avoid re-running code in Worksheet_SelectionChange
Hello --
Today I am more logic- and VBA-challenged than usual. In a workbook, a user can change a cell value by: 1 - double-click a cell to toggle between Y and N or 2 - enter "Y" or "N" (ignore trapping for lower-case entries) After such a change, I want to run AutoFilter code after such a change in cell value; this updates another range in same worksheet Problem: Running AutoFilter code ([a] below) re-triggers Worksheet_SelectionChange How can I prevent re-running code in Worksheet_SelectionChange the second time? Reading this group, it sounds like I should involve Application.EnableEvents=False my code... Application.EnableEvents=True If this is the solution, can someone tell me where to place the "False" and "True"? Do they belong at [b] and [c]? Also, can someone point me to code that returns the user to the cell that was originally clicked? Here is the code I am using: Worksheet_BeforeDoubleClick 'handles user double-clicking in a cell to toggle between "Y" and "N" If Not Intersect(Target, Me.Range("basic_yn")) Is Nothing Then Cancel = True If Target.Value = "Y" Then Me.Range(Target.Address).Value = "N" Else Me.Range(Target.Address).Value = "Y" End If '_SelectionChange handles running filters after double-click to toggle values 'Call Filter_1 'Call Filter_2 End If Worksheet_SelectionChange 'if change a value in column range "basic_yn" re-filter the table 'handles user entering Y or N (ignore trapping for lower-case entries) If Not Intersect(Target, Me.Range("basic_yn")) Is Nothing Then '[a] run autofilters (these trigger further changes in the sheet) 'don't run these again if they have already been run once because of a change in a cell [b] Call Filter_1 Call Filter_2 'return to cell clicked Cells.Range(strNameCellClicked).Select [c] End If Thanks in advance for any help. Larry Mehl --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.797 / Virus Database: 541 - Release Date: 11/15/2004 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Where?Worksheet code module or Worksheet_SelectionChange event han | Excel Worksheet Functions | |||
code in module A to not execute a Worksheet_SelectionChange sub of another module | Excel Discussion (Misc queries) | |||
Worksheet_SelectionChange code: lavish use of system resources? | Excel Discussion (Misc queries) | |||
Adding Worksheet_SelectionChange code by macro | Excel Programming | |||
Insert code into each worksheet's "Sub Worksheet_SelectionChange" Function | Excel Programming |