vba VBA宏搜索自动过滤器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17239180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Macro To Search AutoFilter
提问by Anil Lulla
I currently have a code which searches an AutoFilter, but searches it for exactly what I put within the quotations.
我目前有一个搜索自动过滤器的代码,但搜索它的内容正是我放在引号中的内容。
ActiveSheet.Range(Selection, Selection.End(xlUp)).AutoFilter Field:=5, Criteria1:="CLO "
What I need is a code which will search the filter for the word say "CLO " within each line. So say there's a line which says "CLO has been booked..." I want that to come up in the search. Currently, my search is returning no results since it is searching specifically for "CLO ".
我需要的是一个代码,它将在过滤器中搜索每行中的单词“CLO”。所以说有一行说“CLO 已被预订......”我希望在搜索中出现。目前,我的搜索没有返回任何结果,因为它专门搜索“CLO”。
回答by Jaycal
Update your code with the following
使用以下内容更新您的代码
ActiveSheet.Range(Selection, Selection.End(xlUp)).AutoFilter _
Field:=5, Criteria1:="CLO *"
*
indicates that as long as the text begins "CLO ", the row will be returned, regardless of text follows it.
*
表示只要文本以“CLO”开头,就会返回该行,不管后面的文本如何。