|
楼主 |
发表于 2024-9-4 11:39
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 13602822168 于 2024-9-4 11:41 编辑
谢谢!!!如果想再区分提取好像是不行的?
Sub 获取数据()
With Sheet1
a = .UsedRange
arr = .Range("ej12:je" & UBound(a))
arr1 = .Range("ej1:je3")
jG = .[jG1]
ReDim brr(1 To UBound(arr), 1 To 11)
For i = 1 To UBound(arr1, 2)
If arr1(2, i) = jG Then
n = n + 1
brr(1, n) = arr1(1, i)
brr(2, n) = arr1(2, i)
brr(3, n) = arr1(3, i)
For j = 5 To UBound(arr)
brr(j, n) = arr(j, i)
Next
End If
Next
.Range("jg12").Resize(UBound(arr), 11) = brr
End With
End Sub
Sub 获取数据A()
With Sheet1
a = .UsedRange
arr = .Range("JG12:jQ" & UBound(a))
arr1 = .Range("JG1:JQ3")
jG = .[jS1]
ReDim brr(1 To UBound(arr), 1 To 11)
For i = 1 To UBound(arr1, 2)
If arr1(2, i) = jG Then
n = n + 1
brr(1, n) = arr1(1, i)
brr(2, n) = arr1(2, i)
brr(3, n) = arr1(3, i)
For j = 5 To UBound(arr)
brr(j, n) = arr(j, i)
Next
End If
Next
.Range("jS12").Resize(UBound(arr), 11) = brr
End With
End Sub
|
|