VBA/Excel/Access/Word/Data Type Functions/IsEmpty

Материал из VB Эксперт
Перейти к: навигация, поиск

Test a Variant variable to see whether it has the Empty value

   <source lang="vb">

Sub EmptyVar()

   Dim vntName As Variant
   Debug.Print IsEmpty(vntName) "Prints True
   vntName = ""
   Debug.Print IsEmpty(vntName) "Prints False
   vntName = Empty
   Debug.Print IsEmpty(vntName) "Prints True

End Sub

</source>
   
  


Using the ISEMPTY Function to Check Whether a Cell Is Empty

   <source lang="vb">

Sub isemptyDemo()

   LastRow = cells(Rows.count, 1).End(xlUp).row
   For i = 1 To LastRow
       If isempty(cells(i, 1)) Then
           cells(i, 1).resize(1, 4).Interior.ColorIndex = 1
       End If
   Next i

End Sub

</source>
   
  


Working with Empty and Null

   <source lang="vb">

Sub StringVar()

   Dim strName As String
   Debug.Print IsEmpty(strName) "Prints False
   Debug.Print strName = "" "Prints True

End Sub

</source>