请教高手,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
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)
测试错误.png(17.37 KB)
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
附件

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

2011-8-10 19:50
作者: 7016427 发布时间: 2011-08-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28