LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Problem with Set stmt in Workbook_SheetSelectionChange event

Quick question. I have moved some of this code into my personal.xls
project. I am now using a class module. Where do I put the RenableEvents
sub that was in my Thisworkbook module in the first example. I tried putting
it in the class module but I cannot run it from there. If I put in in the
Thisworbook module of my Personal.xls project, nothing happens when I run it.

'Orignal Code
Sub ReEnableEvents()
Application.EnableEvents = True
End Sub


"OssieMac" wrote:

I tested your code and tried to find a reason. The eternal loop only occurs
when there is a formula in the range. However, it does not call a
Worksheet_Calculate() event so I am at a loss as to why it occurs.

The work around is to use
Application.EnableEvents = False at the start of the sub and
Application.EnableEvents = True at the end of the sub.

It might be superfluous to tell you this but you should keep a copy of the
following code in your module and run it if for any reason the code fails
during your testing before it turns events back on otherwise they remain off
until Excel is restarted. You can run the code from within VBA.

Sub ReEnableEvents()
Application.EnableEvents = True
End Sub


--
Regards,

OssieMac


"ExcelMonkey" wrote:

I am trying to use a Set stmt in a Workbook_SheetSelectionChange event. When
I get to the second Set stmt, the Workbook_SheetSelectionChange event
triggers again and continues to do so in a loop.

Why is this? Why does it only fail on the second one?

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

vOldUsedRange = Worksheets(Target.Parent.Name).UsedRange.Address
Set rngTest = Range(vOldUsedRange)
Set myNumConst = rngTest.Cells.SpecialCells(xlCellTypeConstants, xlNumbers)
End Sub

 
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
Workbook_SheetSelectionChange problem in my add in filo666 Excel Programming 3 January 25th 09 08:29 AM
Workbook_SheetSelectionChange in an Addin rchan11 Excel Programming 3 November 5th 07 03:37 PM
Workbook_SheetSelectionChange in going infinite sency Excel Programming 2 February 17th 07 05:44 AM
Improving Workbook_SheetSelectionChange for enhanced Autofiltering aafraga[_2_] Excel Programming 5 April 10th 06 01:11 PM
Workbook_SheetSelectionChange R.VENKATARAMAN Excel Programming 3 January 23rd 05 11:44 AM


All times are GMT +1. The time now is 06:26 AM.

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

About Us

"It's about Microsoft Excel"