Is blank

Closed
hamam - Oct 23, 2011 at 03:07 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Oct 23, 2011 at 04:54 AM
Hello,
Please help:
I would like a formula that for a cell to turns into a value in case a reference cell is blank and turn to another value if it is not blank.

Thanks a million


1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Oct 23, 2011 at 04:54 AM
you cannot put a formula in a cell referencing this cell itself (leads to circular reference). you can put the formula in another empty cell.

suppose cell reference is in column A form A2 down
then in B2 type a formula
=ilf(A1="",3,5)
you can copy B1 down

this formula meaning is
if A1 is blank than B1 will be 3
if it is not blank B1 will be 5

of course you can write and run a macro to avoid circular reference

Sub test()
Dim r As Range, c As Range
Set r = Range(Range("A2"), Cells(Rows.Count, "A").End(xlUp))
For Each c In r
If c = "" Then
c = 3
Else
c = 5
End If
Next c
End Sub
0