简体   繁体   English

进阶筛选器:Excel VBA

[英]Advanced Filter: Excel VBA

Either using Advanced Filter thru Excel or VBA, I am getting matches to my query string that are acting like a wildcard match. 通过Excel或VBA使用“高级筛选器”,我都得到了与查询字符串匹配的字符串,这些字符串的行为类似于通配符匹配。 Criteria = "On Drug (GPI)" but the results include "On Drug (GPI)" & "On Drug (GPI) w/ Days Supply". 条件=“药品中(GPI)”,但结果包括“药品中(GPI)”和“药品(GPI)w /日供应量”。 How do I get an exact match? 如何获得完全匹配?

Set dataRng = Range("raw_FxnTbl")
            startCol = 2
            endCol = 8
            With sumSh
                .Select
                Set pasteRng = .Range(.Cells(labelRow, startCol), .Cells(labelRow, endCol))
                dataRng.AdvancedFilter _
                    Action:=xlFilterCopy, _
                    CriteriaRange:=critRng, _
                    CopyToRange:=pasteRng, _
                    Unique:=True
            End With

critRng is defined by: critRng由以下方式定义:

'which fxn? '哪个fxn?

With calcSh

    .Select

    .Cells(critRow + 1, critCol).Value = Trim(chosenItem)

    Set critRng = .Range(.Cells(critRow, critCol), .Cells(critRow + 1, critCol))

End With

This is the defined critRng: 这是定义的critRng:

critRow ==> name critRow ==>名称

critRow+1 ==> On Drug (GPI) critRow + 1 ==>药物治疗(GPI)

Try putting this in the criteria cell at critRow+1 : 尝试将其放在critRow+1的条件单元格中:

old text was On Drug (GPI) 旧文本是On Drug (GPI)

Enter this instead: 请输入以下内容:

'=On Drug (GPI)

  • The apostrophe is to avoid Excel interpreting it as a formula. 撇号是为了避免Excel将其解释为公式。

  • The = is to force Excel to make an Exact Match (not case sensitive though). =强制Excel进行Exact Match (尽管不区分大小写)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM