Search code examples
excelvbacellis-empty

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


Solution

  • 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)"