View Single Post
  #12   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 has brought this to us :
On Sep 3, 1:30*pm, GS wrote:
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 athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc- Hide quoted text -

- Show quoted text -


Hi Gary,

No contradiction. I guess I am guilty of not being clear enough.

As for your two examples. Yes, the first is correct. However, The
second is not. The "X" would go to the second row.

The search for the first number greater than zero works in a kind of a
zig zag pattern. Keeping in mind that the search starts with B1 then
(if it finds a zero) it goes DOWN to B2.. (if it again finds a zero)
the search goes to C1..(if it again finds a zero) it goes to C2 and so
on and so forth.


And this is exactly what the code does!!! It will only put an x in the
1st find <0 per pair. If no find then no x in either! Not sure what
you're doing that it doesn't work that way for you but that's how it
works here!

--
Garry

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