IsNull Function in Microsoft Excel
The Excel IsNullFunction is used to determine whether or not a variable has a value assigned or not.
The Basics:
True/False = IsNull(Variable)
Code
Dim variableToEvaluate As Variant variableToEvaluate = Null If IsNull(variableToEvaluate) Then MsgBox "The variable variableToEvaluate has no assigned value"
Output
Note: An effective way to evaluate if a value has been assigned to any variable is to use the following command len(trim(Variable))>0. No matter what type of variable is used if it contains a value this function will identify it.
Code
'Declare variables Dim StringToProcess As String'Variable string to process Dim arrValues() As String'String Array Dim A, B As Long 'Value to use as a counter Dim tmpValue As Variant Dim Check As Boolean StringToProcess = ActiveSheet.Cells(2, 1).Value 'Assign the information to process to our variable
arrValues() = Split(StringToProcess, " ") 'Parse the string into a string array using a space delimiter Counter = 5 For A = LBound(arrValues) To UBound(arrValues) Check = IsNumeric(arrValues(A)) If Check Then ActiveSheet.Cells(Counter, 1).Value = CDbl(arrValues(A)) Counter = Counter + 1 End If Next
Output