Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Worksheet_SelectionChange code: lavish use of system resources?

I wrote some Worksheet_SelectionChange code to augment a large workbook
in use by our company. The routines are not complicated, and just take
care of some routine housekeeping-type chores. The code runs when the
cell pointer lands in a certain cell range; when I explained this
functionality, the guy in charge of version control for this workbook
questioned whether the routines would sponge up excessive system
resources.

Do these routines take up extra processor time, or memory allocation,
or contribute substantially to "overhead" that may cause the
spreadsheet to operate more slowly than it might without the code?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Worksheet_SelectionChange code: lavish use of system resources?

Do you turn off events when you do something so that your code won't cause a
change that would fire your code again (and again and again)?

If yes, then I'd say don't worry about the "overhead".

The only two complaints that I have with events is that sometimes the clipboard
is killed and sometimes it looks too much like magic!



wrote:

I wrote some Worksheet_SelectionChange code to augment a large workbook
in use by our company. The routines are not complicated, and just take
care of some routine housekeeping-type chores. The code runs when the
cell pointer lands in a certain cell range; when I explained this
functionality, the guy in charge of version control for this workbook
questioned whether the routines would sponge up excessive system
resources.

Do these routines take up extra processor time, or memory allocation,
or contribute substantially to "overhead" that may cause the
spreadsheet to operate more slowly than it might without the code?

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Worksheet_SelectionChange code: lavish use of system resources?

Dave-
Thanks for your response- how do I "turn off events"? I don't think
I'm at risk of repetitively triggering the code, but I'd like to know
so I can write better code.

Thanks!


sometimes it looks too much like magic!

LOL!

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Worksheet_SelectionChange code: lavish use of system resources?

In this kind of code:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 Then
Target.Offset(0, 1).Select
End If
End Sub

By selecting something in the code, it triggers the _selectionchange event
again.

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 Then
application.enableevents = false
Target.Offset(0, 1).Select
application.enableevents = true
End If
End Sub

You may find that you change something in the _change event.

This would put the time/date in column F if something changed in A:E:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a:e")) Is Nothing Then
Exit Sub
End If

On Error GoTo errHandler:

With Me.Cells(Target.Row, "F")
Application.EnableEvents = False
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With

errHandler:
Application.EnableEvents = True
End Sub



wrote:

Dave-
Thanks for your response- how do I "turn off events"? I don't think
I'm at risk of repetitively triggering the code, but I'd like to know
so I can write better code.

Thanks!

sometimes it looks too much like magic!

LOL!


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Worksheet_SelectionChange code: lavish use of system resources?

Thanks a million- I'll see how I can apply that to my code.

Reply
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
Excel 2003: Not enough system resources to display completely Lady Layla Setting up and Configuration of Excel 12 October 14th 05 03:41 PM
Change case...help please Terry Excel Worksheet Functions 14 October 2nd 05 12:29 PM
Macro for changing text to Proper Case JPriest Excel Worksheet Functions 3 August 8th 05 09:31 PM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
Not enough system resources to display completly mark Excel Discussion (Misc queries) 0 January 5th 05 04:21 PM


All times are GMT +1. The time now is 07:15 AM.

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"