+ -
当前位置:首页 → 问答吧 → 请教高手,vba如何判断单元格公式错误

请教高手,vba如何判断单元格公式错误

时间:2011-08-10

来源:互联网

比如,sheet1,a=date,b列单元格里的公式错误时,执行宏“aaw”,否则继续执行该单元格公式,这个语句如何写?

作者: 7016427   发布时间: 2011-08-10

sheet1.[b1].formula = "=.................."
if not  intersect(sheet1.[b1], sheet1.SpecialCells(xlCellTypeFormulas, 16)) is nothing then
sheet1.[b1], clear
run "aaw"
end if

作者: livewire   发布时间: 2011-08-10

你好!我把附件上传,请你帮我看看如何改?条件:sheet1.[a]=date,检测到该行b单元格公式错误时,执行宏“aaw”,否则,仍然执行原公式

附件

检测公式.rar(7.4 KB)

2011-8-10 18:55, 下载次数: 0

作者: 7016427   发布时间: 2011-08-10

我测试错误!
Sub aa()
Dim i As Integer
For i = 1 To 31
With Sheet1
If .Range("a" & i) = Date Then
Sheet1.[b1:b31].Formula = "=SUM(RC[1]:RC[8])"
If Not Intersect(.Range("b" & i), Sheet1.SpecialCells(xlCellTypeFormulas, 16)) Is Nothing Then
.Range ("b" & i), Clear
Run "aaw"
End If
End With
Next i
End Sub

附件

检测公式.rar(8.38 KB)

2011-8-10 19:50, 下载次数: 0

测试错误.png(17.37 KB)

2011-8-10 19:50

作者: 7016427   发布时间: 2011-08-10

相关阅读 更多