0

I'm a VBA novice at best. I'm trying to code a button to create an email to send out once all cells in a certain range are completed. I have the following code and I keep getting a runtime error - mistmatch 13 when I go to debug it points to the Range("E13:18"). I'm not sure what I'm doing wrong here. Any help would be greatly appreciated.

Sub btnSendCompletedForm()
    '
    ' btnSendCompletedForm Macro
    ' Send Form
    'Dim MyOutlook As Object

    Dim MyMessage As Object

    Dim SubjectLine As String
    Dim SendOK As Boolean

    SendOK = False

    'Check if fields filled out.

    If Worksheets("NetCert Form").Range("E13:E18") = "" Then  ' Error is here
        Range("E13:E18").Select
        MsgBox ("Please complete all Client User Information.")
    Else
        SendOK = True
    End If

    'Check if OK to send.
    If SendOK Then
GSerg
  • 76,472
  • 17
  • 159
  • 346
  • You are trying to evaluate an array in a single operation as you might in Excel. But this is VBA, not Excel. You need to evaluate each cell one at a time; or use a worksheet function that can evaluate the range. – Ron Rosenfeld Feb 23 '19 at 19:08
  • If you wanted to make sure that all cells in `E13:E18` are not empty, there are several ways to do that. You could see if [`CountA`](https://stackoverflow.com/a/10811619/11683)'s result equals `.Cells.Count`. You could check if [`.SpecialCells(xlCellTypeBlanks)`](https://stackoverflow.com/a/34539547/11683) returns anything. Or you could [loop over](https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/for-eachnext-statement) `.Cells` and see if any one [`IsEmpty`](https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/isempty-function). – GSerg Feb 23 '19 at 19:27

0 Answers0