ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Nothing and Null (https://www.excelbanter.com/excel-programming/278337-using-nothing-null.html)

Mikhail

Using Nothing and Null
 
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



Robin Hammond

Using Nothing and Null
 
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


"Mikhail" wrote in message
...
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






All times are GMT +1. The time now is 12:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com