在我的工作簿中手动运行宏时,我收到运行时错误1004应用程序定义或对象定义错误。这是我开发的代码,它检查单元格中的日期范围,如果它们比今天的日期更早,并且提供的单元格中没有任何数据,则用#34填充它;完成"
Private Sub CommandButton1_Click()
MsgBox "hello"
Dim rCell As Range, rng As Range, rng2 As Range, rCell2 As Range, wksSource As Worksheet
Set wksSource = ActiveWorkbook.Sheets("June")
Set rng = wksSource.Range("B17,B21,B25,B29,B33,B37,B41,B45,B49,B53,B57,B61,B65,B69,B73,B77,B81,B85,B89,B93,B97,B101,B105,B109,B113,B117,B121,B125,B129")
Set rng2 = wksSource.Range("B16:AN16,B28:AN28,B32:AN32,B36:AN36,B40:AN40,B44:AN44,B48:AN48,B52:AN52,B56:AN56,B60:AN60,B64:AN64,B68:AN68,B72:AN72,B76:AN76,B80:AN08,B84:AN84,B86:AN86,B92:AN92,B96:AN96,B100:AN100,B104:AN104,B108:AN108,B112:AN112,B116:AN116,B120:AN120,B124:AN124,B128:AN128")
For Each rCell In rng
'MsgBox rCell.Value
If CDate(rCell.Value) < Date Then
'MsgBox rCell.Value
For Each rCell2 In rng2
If rCell2.Value = "" Then
rCell2.Value = "Complete"
End If
Next rCell2
End If
Next
End Sub
如果我将Set rng = wksSource.Range
减少到几个范围,它似乎运行,这表明可能存在内存问题。有没有办法绕过这个或者我的嵌套语句是否有问题咀嚼RAM?