user4974730
user4974730

Reputation:

"Compile error: Type mismatch"

I have simple VBA program which requires checking a range and telling user whether there are any empty cells -if so, which cells.

The problem line is this:

Dim outputsrange("inputnum+1:inputnum+outputnum") As range

The function:

Sub check()
'   Goal: check if there are any entry truth table cells for outputs
Dim outputsrange("inputnum+1:inputnum+outputnum") As range
If IsEmpty(outputsrange) Then
    MsgBox ("The following cells are empty:" & vbNewLine & emptycell) ' what's the property for these empty cells
End If
End Sub

This gives error:

Compile error:

Type mismatch

How do I fix this type mismatch?

Upvotes: 0

Views: 1818

Answers (1)

user4039065
user4039065

Reputation:

You could try something closer to this.

Dim outputsrange As range
Set outputsrange = Range(inputnum + 1 & ":" & inputnum + outputnum)

With inputnum as 1 and outputnum as 5 that should set outputsrange as rows 2 through 6.

Upvotes: 2

Related Questions