> 其他 >
Exce中 A1到A9与B1到B9单元格对应,C1到C9与D1到D9单元格对应,B列与D列循环相加结果为11时,求A C的数值是多少?有多少组?用VBA代码如何编写?
人气:332 ℃ 时间:2020-01-31 04:10:05
解答
Sub test()
Dim arr,x&,y&,i&,Str1$
arr = Range("A1:D9").Value
For x = 1 To UBound(arr)
For y = 1 To UBound(arr)
If arr(x,2) + arr(y,4) = 11 Then
i = i + 1
Str1 = Str1 & "," & arr(x,1) & "和" & arr(y,3)
End If
Next y
Next x
MsgBox "共" & i & "组,对应A和C的值为:" & Mid(Str1,2,Len(Str1))
End Sub
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版