IF Statement Variable

J

Jase4now

I need to write an IF statement that will look at all the cells in a row, and
if it finds anything, letters or numbers, it then places a "1" in the AA
column of that row.

Thanks
 
C

Chip Pearson

Try something along the lines of

Dim RowNum As Long
RowNum = 1 '<<< CHANGE AS REQUIRED
If Application.CountA(Rows(RowNum)) > 0 Then
Cells(RowNum, "AA").Value = 1
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
P

Pete_UK

Try this formula in AA1:

=1*COUNTA(A1:Z1)>0

or alternatively:

=IF(COUNTA(A1:Z1)>0,"1","")

and copy down the columns for as many rows as you need to look at.

Hope this helps.

Pete
 
E

Elkar

Or, if you'd prefer a formula:

=MIN(1,SUMPRODUCT(--(A1:Z1<>"")))

or

=MIN(1,COUNTA(A1:Z1))

This second formula will consider a blank "" returned by a formula as a
value, whereas the first formula will not.

HTH,
Elkar
 
Top