PC Review


Reply
Thread Tools Rate Thread

Array slowing down event procedure

 
 
bobbo
Guest
Posts: n/a
 
      13th Oct 2006
I wrote the following code to make it easier to read across rows on a
spreadsheet. I declared the array as a public variable in another
module. It works but it is slow. Is there a slicker way of doing this
that is not so slow and returns the rows to their original color?


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
Static OldRange As Range
Dim i As Integer
Dim j As Integer


If Not OldRange Is Nothing Then
For i = 1 To UBound(clrindx, 1)
For j = 1 To 256
Cells(OldRange.Row + i - 1, j).Interior.colorindex = clrindx(i, j)
Next
Next
End If

ReDim clrindx(1 To Selection.Rows.Count, 1 To 256)
For i = 1 To Selection.Rows.Count
For j = 1 To 256
clrindx(i, j) = Cells(ActiveCell.Row + i - 1, j).Interior.colorindex
Next
Next
Target.EntireRow.Interior.colorindex = 15
Target.Interior.colorindex = 6
Set OldRange = Target

End Sub

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      13th Oct 2006
I like Chip's RowLiner add-in to make it easier to read across rows and/or
columns. It applies formatting to the cell borders.

http://www.cpearson.com/excel/RowLiner.htm


"bobbo" wrote:

> I wrote the following code to make it easier to read across rows on a
> spreadsheet. I declared the array as a public variable in another
> module. It works but it is slow. Is there a slicker way of doing this
> that is not so slow and returns the rows to their original color?
>
>
> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
> Target As Range)
> Static OldRange As Range
> Dim i As Integer
> Dim j As Integer
>
>
> If Not OldRange Is Nothing Then
> For i = 1 To UBound(clrindx, 1)
> For j = 1 To 256
> Cells(OldRange.Row + i - 1, j).Interior.colorindex = clrindx(i, j)
> Next
> Next
> End If
>
> ReDim clrindx(1 To Selection.Rows.Count, 1 To 256)
> For i = 1 To Selection.Rows.Count
> For j = 1 To 256
> clrindx(i, j) = Cells(ActiveCell.Row + i - 1, j).Interior.colorindex
> Next
> Next
> Target.EntireRow.Interior.colorindex = 15
> Target.Interior.colorindex = 6
> Set OldRange = Target
>
> End Sub
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set an Event Procedure to User Procedure Cory Microsoft Access Form Coding 3 24th Nov 2008 04:53 PM
slowing/halting stored procedure from ado.net MarcelG Microsoft ADO .NET 8 17th Apr 2008 04:35 AM
Call subform event procedure from main form event procedure ? =?Utf-8?B?cGxj?= Microsoft Access Form Coding 2 26th Oct 2006 10:15 PM
NewExplorer event slowing and breaking outlook shutdown. Dave Townsend Microsoft Outlook Program Addins 10 12th Jan 2005 08:49 PM
Procedure declaration does not match description of event or procedure Paul Camilleri Microsoft Access Form Coding 3 19th May 2004 05:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:38 PM.