我目前正在尝试更改一些预先编写的代码,因此创建了一个虚拟文件。当我试图运行一些测试样本时,我遇到以下错误:
运行时错误' 91':对象变量或未设置块变量
您可以在下面找到代码摘录。
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context{
if ([keyPath isEqualToString:@"allNewsItems"]){ if ([self isBeingPresented]){
[self.tableView reloadData]; }else{
self.mustReloadView = YES;
}
} }
数据表如下:
Sub Button1_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim count As Integer
count = 0
Do While CDate(ws.Cells(2 + count, 1).Value) <= CDate(DateAdd("d", 14, Now()))
count = count + 1
ws.Range("A" & count + 1).Interior.Color = RGB(250, 50, 50)
If CDate(ws.Cells(1 + count, 1).Value) <> CDate(ws.Cells(1 + count, 2).Value) Then
If ws.Range("C" & count + 1) <> "In Sub" Then
ws.Range("C" & count + 1).Interior.Color = RGB(250, 50, 50)
Else
ws.Range("C" & count + 1).Interior.ColorIndex = 44
End If
End If
Loop
...
End Sub
我想我没有正确定义对象,有人可以帮我解决这个问题吗?
提前致谢! 亲切的问候
答案 0 :(得分:1)
声明之后,您需要执行以下操作:
Set wb = ActiveWorkbook
Set ws = wb.Sheets("name")
' if wb is other than the active workbook
wb.activate
ws.Select