LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run Macro on cell exit

Hi Kelly!

How 'bout this:
- copy your procedure code into its own procedure name (e.g. 'foo')
- declare a global boolean variable (e.g. blnRun) and set you
procedure to run only if blnRun is True.
Whenever your code is ready to change a color, set blnRun to False
change your color, then reset blnRun to True again after

i.e.
Code
-------------------


:
:
blnRun = False
{change color code}
blnRun = True
:
:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if blnRun then
call Foo(Target)
end if
End Sub

Private Sub Foo(ByVal targ as Range)
Static rOldCell As Range
If Not rOldCell Is Nothing Then
If Not Intersect(rOldCell, Range("A1")) Is Nothing Then
'your code here
End If
End If
Set rOldCell = targ
End Sub


-------------------




fendwick



*
That worked but I created a new problem.

Within my code I am changeing the interior color of
several diferent ranges and each time I have a ".select"
in my code the "Worksheet_SelectionChange" code runs
again. Sort of like a circular referance I guess?

Anyway is there a way to change the color of a named range
without actually selecting the range and setting off the
Worksheet_SelectionChange code every time?

Other ideas?

Thanks

Kelly


--
Message posted from http://www.ExcelForum.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run macro on exit Steve Excel Discussion (Misc queries) 12 October 25th 09 01:43 PM
Macro on exit cell nonshedders Excel Discussion (Misc queries) 1 April 12th 06 12:41 PM
How do I exit a macro subroutine? John Excel Worksheet Functions 1 January 15th 06 02:08 AM
Exit via macro only? Brisbane Rob Excel Discussion (Misc queries) 1 October 13th 05 01:16 PM
on exit macro ditchy Excel Discussion (Misc queries) 2 May 3rd 05 12:11 AM


All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"