Excel: How to check if a cell is empty with VBA?

Regis Santos picture Regis Santos · Nov 13, 2012 · Viewed 583.8k times · Source

Via VBA how can I check if a cell is empty from another with specific information?

For example:

If A:A = "product special" And B:B is null Then

C1 = "product special"

Illustration of example

Additionally, how can I use a For Each loop on theRange and how can I return the value in the other cell?

Answer

Sylca picture Sylca · Nov 13, 2012

You could use IsEmpty() function like this:

...
Set rRng = Sheet1.Range("A10")
If IsEmpty(rRng.Value) Then ...

you could also use following:

If ActiveCell.Value = vbNullString Then ...