'Using VBA to check if below cell is empty

How do I use VBA in Excel to check if a below cell is empty or not? I want to sum all values in a specific range, but only, if the below cell is not empty.

Is that somehow possible with VBA or any other way?

Example:

4 2 3 2 1
2   3 1

Sum would be: 4 + 3 + 2 = 9.



Solution 1:[1]

Try this simple code

If IsEmpty(ActiveCell.Offset(1, 0)) Then
'your code here
End If

Solution 2:[2]

I've had some problems using just 'IsEmpty' when the data is exported from other databases. This is the function I've developed:

Function IsVacant(TheVar As Variant) As Boolean
  'LeandraG 2010

  IsVacant = False

  If IsEmpty(TheVar) Then IsVacant = True
  If Trim(TheVar) = "" Then IsVacant = True
  If Trim(TheVar) = "'" Then IsVacant = True


End Function

Solution 3:[3]

For those who are desperate: sometimes an Excel cell seems empty, but upon inspection may contain something invisible, such as a space character. And then all those IsEmpty and IsNull functions won't help you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nick
Solution 2
Solution 3 Sander de Jong