Using Nothing and Null

  • Thread starter Thread starter Mikhail
  • Start date Start date
M

Mikhail

What is the difference between Nothing (if Range("A1") is Nothing then ...)
and Null (if IsEmpty(Range("A1") then ...)?
What is better to use with ranges (seems both keywords work)?

Thanks in advance,

Mike510
 
I think this is the general idea.

Nothing applies to an object

Sub
Dim rngCell as range
msgbox (rngCell is nothing) 'should return true
Set rngCell = Range("A1")
msgbox (rngcell is nothing) 'should return false
set rngCell = Nothing 'clears the object

IsEmpty applies to a variable
Dim vTemp as variant
if IsEmpty(vTemp) then ' would be true
vTemp = "Something"
if IsEmpty(vTemp) then ' would be false

Hope that helps,

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in
 
Back
Top