Why Null and IsNull exists? What is the use of it?

makiwara

Board Regular
Joined
Mar 8, 2018
Messages
171
So far it seems to me, that Nulls can be created only MANUALLY.

Like
dim var as variant
var = Null

And you can check this with isNull.


But you can never ever produce a Null value in any of the calculations, no matter what you do. Am I right in this? You can only use it if u create it MANUALLY.

So I don't understand why its useful. I could use instead of null any string for marking a variant, like "Sunshine".
If variant is Sunshine, I do something.

So what is the use of Null? I feel completely confused, sorry :(
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Null is mostly useful when working with databases, but it can actually be returned natively in Excel too. For example, if you were to test the Font.Color of a multiple cell range where one or more cells had a different font colour, it would return Null rather than a number.
 
Upvote 0
Null is mostly useful when working with databases, but it can actually be returned natively in Excel too. For example, if you were to test the Font.Color of a multiple cell range where one or more cells had a different font colour, it would return Null rather than a number.
Thank you for the idea.

Dim z As Variant
z = Range("A3:A4").Font.Color
Debug.Print z '0
Debug.Print IsNull(z) 'false

It would give back 0, but not Null. :/ I still don't understand this, seems overcomplicated.
 
Upvote 0
VBA Code:
With UserForm1.CheckBox1
    .TripleState = True
    .Value = Null
    If IsNull(.Value) Then MsgBox "Checkbox has third value"
End With
 
Upvote 0
Thank you for the idea.

Dim z As Variant
z = Range("A3:A4").Font.Color
Debug.Print z '0
Debug.Print IsNull(z) 'false

It would give back 0, but not Null. :/ I still don't understand this, seems overcomplicated.
Make A3 a different font colour to A4, then run the code again.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top