View Single Post
  #5   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 formulated on Friday :
On Sep 2, 3:52*pm, GS wrote:
GS explained on 9/2/2011 :

Try...


Sub DenoteCellsGreaterTanZero()
* Dim r
* For r = 1 To ActiveSheet.UsedRange.Rows.Count
* * If Application.WorksheetFunction.CountIf(Rows(r), "0") 0 _
* * * *Then Cells(r, 1) = "x"
* Next 'r
End Sub


Note that this is a programming group!
BUT
Since you asked for a formula...

* =IF(COUNTIF(B1:AE1,"0"),"x","")

--
Garry

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


Hey Gary,

I tried both the formula and the macro that you created. Maybe I am
doing something wrong, but it is always returning an "X" in every row
as it will eventually find a number greater than zero. I don't think I
was clear enough in my explanation. What I wanted was an "X" in either
one row or another only once it encounters the number greater than
zero. Therefore, only each set of two rows will contain an "X".... not
both - and of course it must search in the pattern that I previouisly
stipulated.


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.[?] Otherwise, put the x in the 2nd row.[?]

Is Row1 the first row? (ie: sets= 1,2; 3,4; 5,6; ...) OR does the data
start in Row2?

Try...

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" Else Cells(r, 1).Offset(1) = "x"
Next 'r
End Sub

--
Garry

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