Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1461|回复: 0

[习题] 练习(8)

[复制链接]
发表于 2012-6-4 12:12 | 显示全部楼层 |阅读模式
Sub test1()
Dim x As Integer
For x = 1 To 20
If Range("a" & x) = "" Or Range("b" & x) = "" Then GoSub 200
Range("c" & x) = Cells(x, 1) * Cells(x, 2)
Next
Exit Sub
200:
Range("c" & x).Font.Color = vbRed
Range("c" & x) = "空"
x = x + 1
Return
End Sub

Sub test2()
Dim x As Integer
For x = 1 To 20
If Range("a" & x) = 0 Or Range("b" & x) = 0 Then GoTo 200
Range("c" & x) = Cells(x, 1) * Cells(x, 2)
Next
Exit Sub
200:
MsgBox "在第" & x & "行出现零值"
End Sub



Sub test3()
On Error Resume Next
Dim x As Integer
For x = 1 To 20
If x > 13 Then On Error GoTo 0
Range("c" & x) = Cells(x, 1) * Cells(x, 2)
Next
End Sub
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-22 05:02 , Processed in 0.871248 second(s), 6 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表