软件:excel2010
大大拍写
之前询问阵列公式写成VBA已经成功(洒花)
但是第2笔之后的发现数值是错误的
看VBA逐笔运算式,循环数值应该是正确的
但不知为何跑错误的值
档案/示意图/VBA如下
档案http://t.cn/RnPe5vE
示意图https://imgur.com/a/9MhAk
Sub test()
'判断地址不重复数量
ActiveSheet.Range("A1").Select
While ActiveCell.Value <> ""
kkk = ActiveCell.Row
ActiveSheet.Range("A" & kkk).Select
ActiveSheet.Range("V" & kkk) = "地址数"
ActiveSheet.Range("T" & kkk).Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select
ADress_Row = Selection.Rows.Count '判断地址的区间
ActiveSheet.Range("V" & kkk + 1).Value = Application.Evaluate _
("=SUM(If(" & Range("T" & kkk + 1 & ":U" & ADress_Row).Address &
"<>"""",1/COUNTIF(" & Range("T" & kkk + 1 & ":U" & ADress_Row).Address & ","
& _
Range("T" & kkk + 1 & ":U" & ADress_Row).Address & ")))")
ActiveSheet.Range("A" & kkk + 1).Select
'判断选择下个档案名称在哪里
For kkk = ActiveCell.Row To ActiveCell.SpecialCells(xlLastCell).Row
Step 1
If ActiveSheet.Range("A" & kkk) <> "" Then Exit For
Next kkk
ActiveSheet.Range("A" & kkk).Select
Wend
End Sub