Locating Excel files with a specific tab name.

thanos_Z

New Member
Joined
Sep 6, 2018
Messages
3
Hello,
I have a folder with over 3,000 xlsx files. These files contain several tabs with specific names. I am trying to locate which of those files do not have a tab with the name "DOWNLOAD".
I do not want to have to open all 3,000 files and identify which ones do not have this tab. Is there any way to do this with a VBA macro?
Thank you for your assistance.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hello,

with VBA it is possible: If the Workbook are faily small a macro can open them sequentially and check the name of the sheets. If the workbook are big, it might be faster to unzip and then check for the names.



regards
 
Last edited by a moderator:
Upvote 0
I have the below code which identifies all the files and worksheet names but what if i wanted to only identify the files that do not have a worksheet with a specific name. What changes would be need on this code?

Code:
Sub FolderCrawler()
FileType = "*.xls*"
With Application.FileDialog(msoFileDialogFolderPicker)
    .InitialFileName = ThisWorkbook.Path
    .AllowMultiSelect = False
    If .Show = -1 Then
        FilePath = .SelectedItems(1) & "\"
    Else
        Exit Sub
    End If
    
End With
OutputRow = 2
ThisWorkbook.ActiveSheet.Range("A" & OutputRow) = FilePath & FileType
OutputRow = OutputRow + 1
Curr_File = Dir(FilePath & FileType)
Do Until Curr_File = ""
    Set FldrWkbk = Workbooks.Open(FilePath & Curr_File, False, True)
    ThisWorkbook.ActiveSheet.Range("A" & OutputRow) = Curr_File
    ThisWorkbook.ActiveSheet.Range("B" & OutputRow).ClearContents   'Clear any previous values
    OutputRow = OutputRow + 1
    
    For Each Sht In FldrWkbk.Sheets
        ThisWorkbook.ActiveSheet.Range("B" & OutputRow) = Sht.Name
        ThisWorkbook.ActiveSheet.Range("A" & OutputRow).ClearContents 'Clear any previous values
        OutputRow = OutputRow + 1
    Next Sht
    FldrWkbk.Close SaveChanges:=False
    Curr_File = Dir
Loop
Set FldrWkbk = Nothing
ThisWorkbook.ActiveSheet.Range("A" & OutputRow) = "---END OF FOLDER---"
End Sub
 
Upvote 0
Try it first with a 10-20 files, some with and some without the sheet:

Code:
Const Pt As String = "c:\temp\"

Sub F_en()
On Error Resume Next
Application.ScreenUpdating = False
Set WS = ActiveSheet

f = Dir(Pt & "*.xlsx")
Do While Len(f)
    With Workbooks.Open(Pt & f)
        .Sheets("Download").Activate
        If Err.Number <> 0 Then
            lr = lr + 1
            WS.Cells(lr, 1) = .Name
            WS.Cells(lr, 2) = "Download not exist"
            Err.Clear
        End If
        .Close 0
    End With
f = Dir
Loop
Application.ScreenUpdating = True
End Sub

Adopt the path first.
 
Upvote 0
Tried it with a test batch of 10 files for which 2 of them would be a fail. However, i only got a blank page. No results for the files that do not have that specific worksheet name.
Also to mention that some of the files may have several worksheets within it.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top