我有一些工作正常的代码:它从列表中打开文件名,查找它是否包含引号,并将状态返回到列表中,但我添加了一个For循环,发现它只在设置为about时有效“1到10”。任何更大的东西在几个实例中返回错误的值。我错过了什么步骤? (我已经注释掉了这里已删除的额外部分。)
Sub BadCharactersFinder()
Application.ScreenUpdating = False
Dim foundDoubleQuote As Variant
Dim ClientID As String
Dim PDSfilename As String
Dim fname As String
ClientID = ActiveCell.Value
PDSfilename = ActiveCell.Offset(0, 1)
fname = "N:\DOWNLOAD\XYZfoldername\" & ClientID & "\original\" & XYZfilename
For i = 1 To 10
Set WBopener = Application.Workbooks.Open(fname)
Set foundDoubleQuote = ActiveSheet.Cells.Find("""", ActiveSheet.Cells(1, 1), xlValues, xlPart, xlByRows)
If (Not foundDoubleQuote Is Nothing) Then
ActiveWorkbook.Close savechanges:=False
ActiveCell.Offset(0, 15).Value = "Contains quotes"
Else
ActiveWorkbook.Close savechanges:=False
ActiveCell.Offset(0, 15).Value = "."
End If
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Height <> 0
ActiveCell.Offset(1, 0).Select
Loop
Next
End Sub