Bart g
Bart g

Reputation: 585

Check two empty cells in VBA

I have been trying to check if two cells are empty. I know how to check for one cell but I can't get to figure out how to check two separate cells. This is one of the ways I have tried. When I run it, it will only check for F17 but not for F12, if I switch the numbers it will check only for F12. I appreciate any help. Thank you

Sub Button11VerifyFilePathPresent_Click()
Dim rCell As Range

On Error GoTo ErrorHandle
Set rCell = Range("F17", "F12")

If IsEmpty(rCell) Then
    MsgBox "Please select the files" ' "Cell " & rCell.Address & " is empty."
End If

BeforeExit:
Set rCell = Nothing
Exit Sub
ErrorHandle:
MsgBox Err.Description & " Error in procedure CellCheck."
Resume BeforeExit

End Sub

Upvotes: 2

Views: 6714

Answers (1)

Gary's Student
Gary's Student

Reputation: 96791

Consider:

If Range("F17") & Range("F12") = "" Then

If the concatenation is null, then they both must be null.

Upvotes: 2

Related Questions