Excel VBA之类的运算符 [英] Excel VBA like operator

查看:63
本文介绍了Excel VBA之类的运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用excel VBA在另一个字符串中搜索子字符串,如下所示.

I am using excel VBA to search for a substring in another string as below.

Dim pos As Integer
pos = InStr("I am studying at University of Texas at Arlington", "University of Texas")

如果pos返回一个非负值,则表示我在字符串中有子字符串. 但是,我需要更复杂的搜索,其中子字符串可以是"Tex大学" :

If pos returns a non-negative value, it means I have the substring in the string. However, I need a more sophisticated search, where the substring can be "Univ of Tex":

InStr("I am studying at University of Texas at Arlington", "Univ of Tex")

不行.

基于最大搜索词,我需要说一下子字符串存在.可以使用excel VBA吗?

Based on the maximum search terms, I need to say the substring is present. Is it possible using excel VBA?

推荐答案

Like运算符已在VBA中提供:

The Like operator is already available in VBA:

If "I am studying at University of Texas at Arlington" Like "*Univ*of*Texas*" Then
    MsgBox "Yes, it is!"
End If

这篇关于Excel VBA之类的运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆