运行时错误'28':Excel VBA中的堆栈空间不足 [英] Runtime error '28': Out of stack space in Excel VBA
问题描述
我尝试根据自己的需要创建工作簿.第一页包含一个单元格,其类型为文本",其值为DATE值.
I try to a create a workbook for my requirement. The first sheet include a cell which type is 'Text' and it is for DATE value.
如下所示,我在打开工作簿时添加Workbook_Open方法以设置今天的日期.
I add Workbook_Open method for set today date when open the workbook as shown below.
Private Sub Workbook_Open()
Sheet1.Range("F6") = Date
End Sub
我还为该单元格的工作表添加了Worksheet_Change方法.如下进行验证检查.
And I also add Worksheet_Change method for sheet of that cell. That is for validation check as below.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$F$6" Then
'Getting insertion date.
insertionDate = Sheet1.Range("F6")
'If date field is not empty
If insertionDate <> "" Then
Call MsgBox("Insertion Date must be inserted.")
End If
End If
End Sub
之后,我测试了我的代码.打开工作簿时,出现以下错误.
After that, I tested my code. When open the work book, I got the following error.
Run-time error '28':
Out of stack space
单击调试"按钮时,光标将显示在Worksheet_Change方法的第一行.
When click 'Debug' button, the cursor shown at the first line of Worksheet_Change method.
我已经尝试了一切.但是什么也没有发生.帮我.谢谢.
I has tried everything what I thought. But nothing is going on. Help me. Thank You.
推荐答案
我通过这段代码得到了它.我不满意,但是我的问题解决了.
I got it with this code. It is not satisfied for me but my problem is solved.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$F$6" Then
'Getting insertion date.
insertionDate = Sheet1.Range("F6")
'If date field is not empty
If insertionDate <> "" Then
Call MsgBox("Insertion Date must be inserted.")
End If
End If
Application.EnableEvents = True
End Sub
这篇关于运行时错误'28':Excel VBA中的堆栈空间不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!