VBA-Object所需的错误

时间:2017-08-02 02:45:18

标签: excel-vba vba excel

我正在编写一个已经声明了ws的函数。它在命令按钮的私有子下运行​​良好但是当我将其作为函数提取时,它显示了对象所需的错误。该文件太大,我必须将其作为一个函数并调用它,但错误停止了我的程序运行。 任何人都可以帮助我,非常感谢。

If Month(ws.Cells(j, 11)) = "a" And Year(ws.Cells(j, 11)) =  ComboBox1.Text Then  'this sentence error


If ws.Cells(j, 5) <> "-" Then     'this sentence also error if I deleted the above one
n = 2
Else: n = 1
End If
p = 1

0 个答案:

没有答案
相关问题