View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Looking For A Formula

qcan brought next idea :
On Sep 2, 11:13*pm, GS wrote:
Uh, here's a revision that takes into account neither row of a set has
a number 0...

Sub DenoteCellsGreaterThanZero2()
* Dim r As Long
* Dim b1 As Boolean, b2 As Boolean
* For r = 1 To ActiveSheet.UsedRange.Rows.Count Step 2
* * With Application.WorksheetFunction
* * * b1 = (.CountIf(Rows(r), "0") 0)
* * * b2 = (.CountIf(Rows(r).Offset(1), "0") 0)
* * End With 'Application.WorksheetFunction
* * If b1 Then Cells(r, 1) = "x": GoTo nextset
* * If b2 Then Cells(r, 1).Offset(1) = "x"
nextset:
* Next 'r
End Sub

--
Garry

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


Hey Gary,

Close, but not quite. I tried your macro. The macro runs, but it is
not returning the correct info. To answer your questions.....

Ok, so you want it to place an x in the first row of the pair that it
finds a number greater than zero, AND if the 1st row is that row then
ignore the 2nd row.[?]

*** Correct. The same applies if it encounters a number greater than
zero for the first time in the second row, if it still has not
encountered a number greater than zero in the previous first row. In
other words an "X" will be placed in either the first row or second
row - but never both.


That's EXACTLY what the macro does!!!

Example:

00000174090
X 00004645000


This example contradicts your explanation! CLEARLY, the 1st row
contains a number 0 and so the code would put the x in that row and
ignore the 2nd row.

Example:
00000
00001 '//this row gets the x

00001 '//this row gets the x
11111 '//this row gets ignored because above row is 1st row 0

Is Row1 the first row? (ie: sets= 1,2; 3,4; 5,6; ...)

*** Yes, it starts in row 1, and yes, the sets are 1,2; 3,4; 5,6
etc....


--
Garry

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