What is the difference between =Empty and IsEmpty() in VBA (Excel)?

前端 未结 3 1023
长发绾君心
长发绾君心 2020-12-01 12:17

I have used the following VBA code:

Do While .Cell(i,1) <> Empty
  \' doing things
  i = i+1
Loop

to iterate through columns (with Do

3条回答
  •  情歌与酒
    2020-12-01 12:52

    Empty refers to a variable being at its default value. So if you check if a cell with a value of 0 = Empty then it would return true.

    IsEmpty refers to no value being initialized.

    In a nutshell, if you want to see if a cell is empty (as in nothing exists in its value) then use IsEmpty. If you want to see if something is currently in its default value then use Empty.

提交回复
热议问题