【问题标题】:"Compile error: Type mismatch"“编译错误:类型不匹配”
【发布时间】:2015-12-13 01:02:46
【问题描述】:

我有一个简单的 VBA 程序,它需要检查一个范围并告诉用户是否有空单元格 - 如果有,哪些单元格。

问题是这样的:

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

功能:

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

这给出了错误:

编译错误:

类型不匹配

如何解决这种类型不匹配的问题?

【问题讨论】:

  • 你的编译器会告诉你不匹配出现在哪一行吗?

标签: vba excel


【解决方案1】:

你可以尝试一些更接近这个的东西。

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

inputnum 为 1,outputnum 为 5,应该将输出范围设置为第 2 到第 6 行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多