我有两个变量Temp
和aw
,它们都是工作簿。我想测试aw
是否为空,如果是,则将其指定为activeworkbook。我试过了
if len(aw) = 0 then
set aw = activeworkbook
但我一直收到错误。
Static aw As Workbook
Dim Temp As Workbook
Set Temp = ActiveWorkbook
If Temp = aw Then
GoTo Here
ElseIf Len(aw) = 0 Then
Set aw = ActiveWorkbook
Else
Application.ScreenUpdating = False
aw.Activate
ActiveSheet.Range("K5:K7").Clear
Set aw = Temp
aw.Activate
Application.ScreenUpdating = True
End If
Here:
aw.Activate
ActiveSheet.Range("K5").Select
Selection.Value = 15 * 60
答案 0 :(得分:3)
Len
函数用于确定字符串的长度。它不接受Workbook对象作为输入。 (不清楚工作簿的“长度”是什么意思!)
您要做的是测试aw
是否为Nothing:
If aw Is Nothing Then Set aw = ActiveWorkbook