如何在过滤后处理没有值

时间:2016-11-28 13:02:19

标签: excel vba excel-vba

这是我的数据库: This is my data base

现在,这是我的表"产品":

enter image description here

这就是我的表格"文章":

enter image description here

我有这段代码可以实现:

    ' 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

整个代码有点长,这就是我添加文件的原因,随意下载以了解整个代码。

它完美无缺,除非有一个完整的(标题除外)空列,如下所示:

enter image description here

一些帮助会被贬低。

下载文件的链接:https://drive.google.com/file/d/0B5DpGwPWsIfbUjlueHBjTU50Mzg/view?usp=sharing

1 个答案:

答案 0 :(得分:1)

你可以这样(见注释行):

out = (B .* B.') .* reshape(B, 1, 1, []);