[英]Excel VBA "Like" not Selecting for "*M*"
The following code executes the "Then" statement for a folder with the name of "2017-10-16" without an "M", even though the code seems to require that it both have an "M" and a date as well.以下代码为名称为“2017-10-16”而没有“M”的文件夹执行“Then”语句,尽管该代码似乎要求它同时具有“M”和日期。 Does anyone know why the first part of the statement is returning true for a folder without an "M", or what else may be going on here?
有谁知道为什么语句的第一部分对于没有“M”的文件夹返回 true,或者这里可能发生了什么?
If _
objSubFolder.Path Like "*M*" And _
objSubFolder.Path Like "*" & Format(DateLoop, "yyyy-mm-dd") & "*" _
Then
MsgBox objSubFolder.Name
I was using the .Path method instead of the .Name method, so I was pulling the entire path instead of the folder name.我使用的是 .Path 方法而不是 .Name 方法,所以我拉的是整个路径而不是文件夹名称。
If _
objSubFolder.Name Like "*M*" And _
objSubFolder.Name Like "*" & Format(DateLoop, "yyyy-mm-dd") & "*" _
Then
MsgBox objSubFolder.Name
Works.作品。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.