Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Array slowing down event procedure

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Array slowing down event procedure

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
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
Event Procedure doesn't run pat59 Excel Programming 3 July 19th 06 04:00 PM
How to call an event procedure Ben Excel Programming 2 December 6th 05 05:40 PM
Event Procedure Paul Johnson[_2_] Excel Programming 1 February 2nd 05 01:29 PM
Event Procedure again Paul Johnson[_2_] Excel Programming 1 February 2nd 05 01:28 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 02:02 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"