Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Looking For A Formula

Ron,
In my previous example, it doesn't work very fast if processing
thousands of rows because while it reads the entire set in one step, it
writes the output range each iteration of the inner loop that finds 0.
To speed the process up I revised the macro to read/write the ranges in
one step each so the entire process is done in memory before writing
back to the wks, as follows:

Sub FindFirstCellGreaterThanZero2()
' Finds the 1st cell that contains 0 in a set of row pairs
Dim vTemp As Variant, vResults() As String
Dim lRow As Long, lCol As Long, j As Long, r As Long

lCol = Cells.Find(What:="*", _
After:=Cells(Rows.Count, Columns.Count), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Column
lRow = Cells(Rows.Count, 2).End(xlUp).Row
ReDim vResults(0, lRow)

Columns(1).ClearContents
Application.ScreenUpdating = False
For r = 1 To lRow Step 2
vTemp = Range(Cells(r, 2), Cells(r + 1, lCol))
For j = 1 To lCol - 1
If vTemp(1, j) 0 Then
vResults(0, r - 1) = "X": GoTo nextset
ElseIf vTemp(2, j) 0 Then
vResults(0, r) = "X": GoTo nextset
End If
Next 'j
nextset:
Next 'r
Range("A1").Resize(lRow, 1) = _
Application.WorksheetFunction.Transpose(vResults)
Application.ScreenUpdating = True
End Sub

Also, I added the following ConditionalFormatting concept (by Chip
Pearson) to shade every other pair of rows 'light green'.

Select the range to be evaluated (in this case "A1:AE30")
Add CF formula: =MOD(ROW()-Rw,N*2)+1<=N
Set the desired color for row shading

The above formula starts shading in 'odd' sets (ie: 1st,3rd,...).

If you want the shaded sets to start 'even' (ie: 2nd,4th,...), use the
following formula instead.

=MOD(ROW()-Rw,N*2)+1N

Note that in the above formulas you need to replace the placeholders Rw
and N with your values as follows:

Rw: The 1st row number to begin shading.
N: The number of consecutive rows to shade.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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
Regression Leverage Formula (Jerry W. Lewis or Mike Middleton)already have DFITS formula PJ[_3_] Excel Worksheet Functions 2 June 2nd 10 03:45 PM
Excel Formula Guidance. Formula need to determine if cell is popul Matt Excel Programming 0 February 19th 10 07:32 PM
copy formula down a column and have cell references change within formula brad New Users to Excel 5 May 13th 07 04:38 PM
Formula expected end of statement error, typing formula into cell as part of VBA macro [email protected] Excel Programming 1 July 20th 06 07:58 PM
Commenting custom formula fields/formula on formula editor Muxer Excel Programming 2 July 24th 03 01:02 AM


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