|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 排列()
arr = [a2:c65]
ReDim brr(1 To UBound(arr), 1 To 2)
ReDim crr(1 To UBound(arr), 1 To 2)
ReDim drr(1 To UBound(arr) * 2, 1 To 2)
For i = 1 To UBound(arr)
If arr(i, 3) = "A" Then
k = k + 1
brr(k, 1) = arr(i, 1)
brr(k, 2) = arr(i, 2)
Else
j = j + 1
crr(j, 1) = arr(i, 1)
crr(j, 2) = arr(i, 2)
End If
Next
For i = 1 To UBound(brr) - 2
x = x + 2
drr(x, 1) = brr(i, 1)
drr(x, 2) = brr(i, 2)
drr(x + 1, 1) = crr(i, 1)
drr(x + 1, 2) = crr(i, 2)
Next
Range("d2").Resize(UBound(arr) * 2, 2) = drr
End Sub |
|