Using Nothing and Null

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
 
R

Robin Hammond

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top