excel vba 运行时错误 7 - 内存不足
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14383991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
excel vba runtime error 7 - out of memory
提问by evoandy
I have two macros in a worksheet. The first one check whether certain cells are addressed and have certain values then runs another macro. The following code is used for this:
我在工作表中有两个宏。第一个检查某些单元格是否已寻址并具有某些值,然后运行另一个宏。以下代码用于此目的:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("K10:K1000")) Is Nothing And Target.Value = "Trapezoidal roof 0.6mm and above" Or Target.Value = "LightBox ballasted" Then
Application.ScreenUpdating = False
Call PPAPricePerkWp
End If
End Sub
This works fine on it's own.
这本身就很好用。
The second macro is run when a button is clicked. This macro copies and pastes cells/rows to other parts of the spreadsheet.
当单击按钮时运行第二个宏。此宏将单元格/行复制并粘贴到电子表格的其他部分。
When the macro is run I get the error Runtime error 7 - out of memory
and it breaks on the above bit of code.
当宏运行时,我收到错误Runtime error 7 - out of memory
,它在上面的代码位上中断。
Is there another way I can check whether cells in a certain column are addressed and have certain values and won't lead to the above error?
有没有另一种方法可以检查某个列中的单元格是否已寻址并具有某些值并且不会导致上述错误?
回答by SeanC
you might want to disable events before you call your subroutine, so that the Worksheet_Change is not being triggered every time you change a cell
您可能希望在调用子程序之前禁用事件,以便每次更改单元格时都不会触发 Worksheet_Change
Application.EnableEvents = False
Application.EnableEvents = False
Don't forget to turn it back on when you are finished
完成后不要忘记重新打开它