
Originally Posted by
mohan.r1980
Hi Experts,
i have multiple folders and have multiple excel files in it.
i am trying to open each folder and open each excel file
when i open excel file of that particular folder i have extract some date from the sheet Name ("Enter Data").
Problem is that some of the excel have no such type of sheets so i just want to know how do i check the sheet name "Enter Data") is available or not
Please suggest.
My Code is below
For Each m In mFol.SubFolders
sFileName = Dir(m.Path & "\*.xls*")
Do While Len(sFileName) > 0
Workbooks.Open (m.Path & "\" & sFileName)
Sheets("ENTER DATA").Select
ActiveWorkbook.Close False
sFileName = Dir
Loop
Next m
Not test maybe like this
sub test()
Dim myfile as object,f as object
Dim s as string
Dim fso as object,arr(),j as long
Set fso = CreateObject("Scripting.FileSystemObject")
s ="Enter Data"
Set f =fso.Getfolder("your path")
For each myfile in f.subfolders.files
Dim wb as workbook,ws as worksheet
Set wb = Workbooks.open(myfile)
With wb
If not Evaluate("isreff('" & s & "'!A1")") then
j = j + 1
Redim Preserve arr(1 to j)
arr(j) = wb.name
End if
.close ,false
End with
Next myfile
Dim v
For each v in arr
Msgbox "This file " & v & " Not have sheet Enter Data",64
Next v
End sub
Bookmarks