Why Does vbNull = 1

biocentrism

Board Regular
Joined
Jul 28, 2014
Messages
187
I have the formula below. But instead of inserting a Blank, it inserts the value of 1. Why is this and how can I insert a blank? I know I can use "", but I read somewhere that it is better to use vbNull instead of "". Am I doing something wrong?

Code:
cel.Value = vbNull

Furthermore, when used in other places vbNull can also return a value of -1 and 65535.

Anyone know what is going on here?

Thank you.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
vbNullString is the alternative to ""

vbNull is a Variable Type constant. meaning that if one has a variable, x, vbNull is one of the possible values of VarType(x)

Code:
Dim x As Variant
x = Null
MsgBox VarType(x) = vbNull
 
Upvote 0
Thank you. If I have a datatype = Double, how do I insert a blank?

I have tried =Nul and =Empty, but they all insert a value of some sort (usually 0).
 
Upvote 0
Code:
cel.ClearContents
 
Upvote 0

Forum statistics

Threads
1,207,097
Messages
6,076,556
Members
446,213
Latest member
bettigb

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