Код: Выделить всё
Sub all()
Range(Cells(8, 1), Cells(8, 14).End(xlDown)).Clear
iPath = ThisWorkbook.Path & "\"
iFileName = Dir(iPath & "*.DBF")
On Error GoTo ErrHandler
iPath = ThisWorkbook.Path & "\"
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
.Calculation = xlAutomatic
With .Filesearch
.NewSearch
.LookIn = iPath
.SearchSubFolders = True
.FileName = "*231?.dbf"
.FileType = msoFileTypeExcelWorkbooks
.Execute
error:
For iCount& = 1 To .FoundFiles.Count
With Workbooks.Open(FileName:=.FoundFiles(iCount&), UpdateLinks:=0)
If Union(Range(Cells(2, 6), Cells(2, 8).End(xlDown)), Range(Cells(2, 10), Cells(2, 20).End(xlDown))).Value = NotNull Then
GoTo error
End If
Union(Range(Cells(2, 6), Cells(2, 8).End(xlDown)), Range(Cells(2, 10), Cells(2, 20).End(xlDown))).Copy
Application.DisplayAlerts = False
Windows("an_231z.XLS").Activate
Worksheets("231z").Cells(Worksheets("231z").Cells(65536, 1).End(xlUp).Row + 1, 1).Activate
ActiveSheet.Paste
Application.DisplayAlerts = False
End With
Next
Application.DisplayAlerts = False
End With
ErrHandler:
.EnableEvents = True
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub