|
楼主 |
发表于 2010-8-16 16:09
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
回复 1989楼 语过添情 的帖子
在已使用的行内进行循环。
调用sumif函数,判断是否数值相减为0,满足条件的填入"已勾对“
- Sub ggsmart()
- Dim i As Long, xrow As Long, rng As Range, cel As Range, jf As Double, df As Double
- xrow = Range("A1").CurrentRegion.Rows.Count
- Set rng = Range("B2:B" & xrow)
- For i = 2 To xrow
- Set cel = Cells(i, "B")
- jf = Application.WorksheetFunction.SumIf(rng, cel, rng.Offset(0, 1))
- df = Application.WorksheetFunction.SumIf(rng, cel, rng.Offset(0, 2))
- If jf = df Then
- cel.Offset(0, 3) = "已勾对"
- Else
- cel.Offset(0, 3) = ""
- End If
- Next
- End Sub
复制代码
[ 本帖最后由 ggsmart 于 2010-8-16 16:18 编辑 ] |
|