[ACCEPTED]-How to check a variable if it have a value or not?-excel
Accepted answer
Depends what you are testing.
A range object 1 or a cell value?
Sub test()
Dim rngObject As Range
Dim value As Variant
Set rngObject = Sheet1.Range("A1:D5")
If Not rngObject Is Nothing Then
'If not nothing then run this code
End If
value = rngObject.Cells(1, 1).value
If Not IsEmpty(value) Then
'if Not empty then run this code
End If
If value <> vbNullString Then
'if value is not nullstring then run this code
End If
End Sub
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.