禁止ls:使用wc传递管道时不匹配。
Dim d1 As Date, d2 As Date
Dim iErr As Long
On Error Resume Next
d1 = CDate(Range("A1"))
If Err.Number <> 0 Then
Err.Raise Err.Number ' handle error
Stop ' it makes no sense to keep running
End If
On Error Goto 0
For j = Last To 1 Step -1
On Error Resume Next
d2 = CDate(Cells(j, 1))
iErr = Err.Number
On Error GoTo 0
If iErr = 0 Then
If d1 > d2 ....
Else
If iErr <> 13 Then ' suppress type mismatch error
Err.Raise iErr ' other error, raise
Stop
End If
End If
Next
如何在保持如上所述的字数的同时抑制Activesheet
?
答案 0 :(得分:0)
可以使用find代替ls。
pglc00524> ls /tmp/kinhwa
aa ab ca
pglc00524 ls /tmp/kinhwa/*d* | wc
ls: No match.
0 0 0
pglc00524> find /tmp/kinhwa/ -maxdepth 1 -name '*d*' | wc
0 0 0
pglc00524> find /tmp/kinhwa/ -maxdepth 1 -name '*a*' | wc
4 4 58
答案 1 :(得分:0)
假设您使用的是 csh
,您可以抑制 ls
和 find
等命令的“不匹配”输出,
set nonomatch=1