|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 多条件调用数据()
- arr = Range("a1").CurrentRegion
- brr = Sheets("以往数据").Range("a1").CurrentRegion
- ReDim crr(1 To UBound(arr), 1 To 1)
- For x = 2 To UBound(arr)
- For y = 2 To UBound(brr)
- ' If arr(x, 1) & arr(x, 2) & arr(x, 3) = brr(y, 1) & brr(y, 2) & brr(y, 3) Then
- ' crr(x - 1, 1) = brr(y, 4)
- ' Exit For
- ' End If
- If brr(y, 1) = arr(x, 1) And brr(y, 2) = arr(x, 2) And brr(y, 3) = arr(x, 3) Then
- m = m + 1
- crr(m, 1) = brr(y, 4): Exit For '如果记录是一对多,则不能用exit for
- End If
- Next
- Next
- Sheets("sheet1").Range("d2").Resize(x - 1) = crr
- End Sub
复制代码 |
|