首页 > 解决方案 > Right 函数是否具有通配符功能?

问题描述

我正在尝试删除以“DL1”和“DL2”和“DL3”等结尾的字符串。

我遇到了带有通配符功能的 Right 函数,但是,它不能以这种方式工作。

sub removingDL()
dim item_description as string
dim i as integer
dim x as integer

item_description = cells(i,x)
if (Right (item_description,3) = "DL?") then   ' the issue is here 
    'remove it, let's just assume
end if 

end sub

标签: excelvbawildcard

解决方案


使用Like.

If item_description Like "*DL?" Then...

如果您打算遍历一个范围(不清楚这是否是您的最终目标),您可以AutoFilter使用Criteria1:="=*DL?"而不是循环。


推荐阅读