Hi Guys,
Please indulge me in the following problem. I need to parse over 700 files in order to establish if they contain or not a specific sheet "Corrective Saccades". If this particular sheet is present in the file, I would like to rename that file, or rename/delete the files that are not containing that specific sheet - whatever is easier.
An example file is here: Corrective Saccades.xlsx
Please see my piece of code below. Many thanks in advance!
Please indulge me in the following problem. I need to parse over 700 files in order to establish if they contain or not a specific sheet "Corrective Saccades". If this particular sheet is present in the file, I would like to rename that file, or rename/delete the files that are not containing that specific sheet - whatever is easier.
An example file is here: Corrective Saccades.xlsx
Please see my piece of code below. Many thanks in advance!
VBA Code:
Sub LoopFiles()
Dim xFd As FileDialog
Dim xFdItem As Variant
Dim xFileName As String
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
If xFd.Show = -1 Then
xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
xFileName = Dir(xFdItem & "*.xls*")
Do While xFileName <> ""
With Workbooks.Open(xFdItem & xFileName)
'your code here
For Each xWs In Application.ActiveWorkbook.Worksheets
If xWs.Name = "Corrective Saccades" Then
[B] WHAT DO I DO NEXT?[/B]
End If
Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
ActiveWorkbook.Save
ActiveWorkbook.Close
End With
xFileName = Dir
Loop
End If
End Sub