当前位置:网站首页>Excel VBA quick start (XII. Common usage of like comparison)
Excel VBA quick start (XII. Common usage of like comparison)
2022-07-26 22:11:00 【Three uncle notes】
List of articles
grammar : character string Like Base string , Written in Like On the right , Wildcard pairs can be used Like Make a fuzzy comparison with the content on the left
1. Ignore a character comparison
Using wildcards ?, use ? The placeholder can be any character , But it can't be empty
Public Sub main()
Debug.Print " character string " Like "? Fu string " ' result :True
Debug.Print " character string " Like " character ?" ' result :True
Debug.Print " character string " Like " word ? strand " ' result :True
Debug.Print " character string " Like "? character string " ' result :False
End Sub
2. Ignore multiple character comparisons
Using wildcards *, use * The placeholder can be any number of any character
Public Sub main()
Debug.Print " character string " Like "* strand " ' result :True
Debug.Print " character string " Like " word *" ' result :True
Debug.Print " character string " Like " word * strand " ' result :True
Debug.Print " character string " Like "* character string " ' result :True
End Sub
3. Cancel the meaning of wildcard
Sometimes in the benchmark string on the right , Want wildcards to have no special meaning , Just like an ordinary character , Then you can use [] To cancel the wildcard
meaning , Make it an ordinary character
Public Sub main()
' Like On the right side of the [?] No wildcard function , It's just an ordinary character “?"
Debug.Print " word ? strand " Like " word [?] strand " ' result :True
Debug.Print " character string " Like " word [?] strand " ' result :False
End Sub
4. Compare digit numbers
Using wildcards # You can judge the number of digits , One # Is a , Two # Just two , And so on
Public Sub main()
Debug.Print 100 Like "###" ' result :True
Debug.Print 1000 Like "###" ' result :False
End Sub
5. Interval comparison
Interval comparison is best based on regular expressions , Because syntax is very similar to regular , Write the interval value in [] Inside
Public Sub main()
Debug.Print "A" Like "[a-zA-Z]" ' A character , And the characters are in lowercase a-z And capital A-Z Between "
Debug.Print "M" Like "[A-GM-Z]" ' A character , And the characters are in uppercase A-G And capital M-Z Between "
Debug.Print "Y" Like "[!A-G]" ' A character , And the characters are not capitalized A-G Between "
Debug.Print "C" Like "[ABCD]" ' A character , And the characters are in uppercase ABCD Between "
Debug.Print "A125Z" Like "[A-C]*[Y-Z]" ' At least two characters , The first character is in uppercase A-C Between , The last character is in Y-Z Between
End Sub
边栏推荐
猜你喜欢
随机推荐
ZABBIX calls API retrieval method
jmeter -- response中文乱码处理
JS verify complex password
仅需一个依赖给Swagger换上新皮肤,既简单又炫酷~
08 du 命令
同花顺上面开户安全吗,开户怎么选券商
Ansible installation and use
A bowl of noodles in a dream
45、实例分割的labelme数据集转coco数据集以及coco数据集转labelme数据集
iptables防止nmap扫描以及binlog实现增量备份
第15章 mysql用户管理
Is it safe to open an account on flush? How to choose a securities firm for opening an account
09 expr command
When deploying Flink on a single machine and creating the connection table of oracle19c RAC, the error ora-12505 is reported. Who can help
Implementation of MATLAB short-time autocorrelation
matlab 激励模型 三角波频谱
In depth interpretation of happens before principle
2018 arXiv preprint | MolGAN: An implicit generative model for small molecular graphs
npm, npm中文文档, npm学习使用
C data type_ From rookie tutorial









![[mysql]substr usage - query the value of specific digits of a field in the table](/img/d5/68658ff15f204dc97abfe7c9e6b354.png)