Le Viet Hung
Le Viet Hung

Reputation: 529

Check if cell in excel is empty or blank

I have a question about checking cells is empty in Excel VBA. I did it with 0 but don't know how to do it with blank or empty.

Code:

  ActiveCell.FormulaR1C1 = "=1000/(IF( RC[-2] = 0,100000000,RC[-2]))"

What i want it, if RC[-2] = 0 or empty, then RC[-2]= 100000000, if not then RC[-2]

something like: "=1000/(IF( OR(RC[-2] = 0, RC[-2]= Empty),100000000,RC[-2]))" but this code doesn't do it

Upvotes: 0

Views: 4686

Answers (2)

Spas
Spas

Reputation: 860

Try with IsEmpty instead of IsBlank.

Upvotes: 0

Larry
Larry

Reputation: 2794

EDIT: Can work for Cell format in TEXT

to serve your requirement:

   ActiveCell.FormulaR1C1 = "=IF(NOT(ISBLANK(RC[-2])),IF(AND(ISNUMBER(VALUE(RC[-2])),VALUE(RC[-2])<>0),1000/VALUE(RC[-2]),0.000001),0.000001)"

Upvotes: 2

Related Questions