假定文件夹为:E:\ABC,单元格为A1,代码如下:
wjm = Dir("E:\ABC\*.*")
Do While wjm <> ""
If InStr(wjm, [A1]) > 0 Then Exit Do
wjm = Dir
Loop
If wjm = "" Then [A1].Interior.ColorIndex = 3‘设置背景色为红色
假设文件夹为 mypath, 单元格A1
ifile=dir(mypath)
do while ifle<>""
if instr(ifile,"B223")>0 then goto 100
ifile=dir
loop
'标记颜色
cells(1,1).Interior.ColorIndex = 5 '标为蓝色
100 exit sub