现在,这是我的表"产品":
这就是我的表格"文章":
我有这段代码可以实现:
' Extract Products
ReDim Preserve aProducts(2 * .Rows.Count)
lRow = 1
sCriteria = "Produit"
aProducts(lRow) = Array("Id Product", "Value A", "Value B", "Value C")
aHdr = Array("Id product", "Value A", "Value B", "Value C", _
"Type of value A", "Type of value B", "Type of Value C")
GoSub Get_Field_Post
' Extract Products - Value A
b = aPos(5)
.AutoFilter Field:=b, Criteria1:=sCriteria
For Each vItm In .Offset(1, 0).Resize(-1 + .Rows.Count) _
.SpecialCells(xlCellTypeVisible).Rows
With vItm
lRow = 1 + lRow
aProducts(lRow) = Array(.Cells(aPos(1)).Value2, _
.Cells(aPos(2)).Value2, Empty, Empty)
End With
Next
.AutoFilter Field:=b
整个代码有点长,这就是我添加文件的原因,随意下载以了解整个代码。
它完美无缺,除非有一个完整的(标题除外)空列,如下所示:
一些帮助会被贬低。
下载文件的链接:https://drive.google.com/file/d/0B5DpGwPWsIfbUjlueHBjTU50Mzg/view?usp=sharing
答案 0 :(得分:1)
你可以这样(见注释行):
out = (B .* B.') .* reshape(B, 1, 1, []);