|
楼主 |
发表于 2022-11-8 13:45
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 试试()
Dim a, b, c, d, e, f, g, h, a2, b2, c2, d2, e2, f2, g2, h2 As Integer
Dim ARR1, ARR2, ARR3, ARR4, ARR5, ARR6, ARR7, ARR8, brr1(), brr2(), brr3()
Dim m, n, o, p, m1, m2, m3, m4, m5, m6, m7 As Integer
m = 0
n = 0
o = 0
p = 3
m1 = 1
m2 = 1
m3 = 1
m4 = 1
m5 = 1
m6 = 1
m7 = 1
a = Range("CD2").Value
b = Range("CE2").Value
c = Range("CF2").Value
d = Range("CG2").Value
e = Range("CH2").Value
f = Range("CI2").Value
g = Range("CJ2").Value
h = Range("CK2").Value
a2 = a + 2
b2 = b + 2
c2 = c + 2
d2 = d + 2
e2 = e + 2
f2 = f + 2
g2 = g + 2
h2 = h + 2
ARR1 = Range("CD" & 3 & ":CD" & a2)
ARR2 = Range("CE" & 3 & ":CE" & b2)
ARR3 = Range("CF" & 3 & ":CF" & c2)
ARR4 = Range("CG" & 3 & ":CG" & d2)
ARR5 = Range("CH" & 3 & ":CH" & e2)
ARR6 = Range("CI" & 3 & ":CI" & f2)
ARR7 = Range("CJ" & 3 & ":CJ" & g2)
ARR8 = Range("CK" & 3 & ":CK" & h2)
For m1 = 1 To b
For m2 = 1 To c
If ARR2(m1, 1) = ARR3(m2, 1) Then
m = m + 1
ReDim Preserve brr1(1 To m)
brr1(m) = ARR1(m1, 1) & ARR2(m1, 1) & ARR4(m2, 1)
For m3 = 1 To e
If Right(brr1(m), 2) = ARR5(m3, 1) Then
n = n + 1
ReDim Preserve brr2(1 To n)
brr2(n) = brr1(m) & ARR6(m3, 1)
For m4 = 1 To g
If Right(brr2(n), 2) = ARR7(m4, 1) Then
o = o + 1
ReDim Preserve brr3(1 To o)
brr3(o) = brr2(n) & ARR8(m4, 1)
Range("CL" & p) = brr3(o)
p = p + 1
End If
Next m4
End If
Next m3
End If
Next m2
Next m1
MsgBox ("完毕")
End Sub
谢谢回复,以上代码自己搞定。完美实现。是根据百度和本论坛指点完成的。但是从门外往门里进,缺少基础,虽完成,但还有一些语句不是很透彻。不过逻辑还是论坛帮助打通的。 |
|