Hi
I was hoping someone might be able to help me this.
I've got the macro which loops through a list of files within an excel column, but I need to then have the macro loop through the opened files' sheet tabs to see if it contains a sheet specifically contains "Data Table".
If such a tab is found I need it to be marked as found in the cell next to the file name.
The code I have is below, currently it seems to be opening each listed file but a) is only looking at worksheet 1 (how do you specify ALL worksheets?), and also does not add the text "Data Table", instead the document remains open.
I'm pretty new to this so sorry if the code is bizarre...
Sub DataTable_Loop()
Dim ThisFileName, FileToOpen As String
ThisFileName = ActiveWorkbook.Name
Range("a1").Select
Do While ActiveCell <> ""
FileToOpen = ActiveCell
Workbooks.Open(Filename:=FileToOpen).RunAutoMacros Which:=xlAutoOpen
ActiveWorkbook.Worksheets.Select
If Worksheets(1).Name = "Data_Table" Then
WBFound = True
'WBName = wb.Name
If WBound = True Then
ActiveWorkbook.Close
Windows(ThisFileName).Active
ActiveCell.Offset(0, 1) = "Data_Table"
End If
'Exit For
Else
ActiveWorkbook.Close
'Windows(ThisFileName).Active
'ActiveCell.Offset(0, 1) = "None"
End If
'Exit For
Windows(ThisFileName).Activate
ActiveCell.Offset(1, 0).Range("a1").Select
Loop
End Sub
I was hoping someone might be able to help me this.
I've got the macro which loops through a list of files within an excel column, but I need to then have the macro loop through the opened files' sheet tabs to see if it contains a sheet specifically contains "Data Table".
If such a tab is found I need it to be marked as found in the cell next to the file name.
The code I have is below, currently it seems to be opening each listed file but a) is only looking at worksheet 1 (how do you specify ALL worksheets?), and also does not add the text "Data Table", instead the document remains open.
I'm pretty new to this so sorry if the code is bizarre...
Sub DataTable_Loop()
Dim ThisFileName, FileToOpen As String
ThisFileName = ActiveWorkbook.Name
Range("a1").Select
Do While ActiveCell <> ""
FileToOpen = ActiveCell
Workbooks.Open(Filename:=FileToOpen).RunAutoMacros Which:=xlAutoOpen
ActiveWorkbook.Worksheets.Select
If Worksheets(1).Name = "Data_Table" Then
WBFound = True
'WBName = wb.Name
If WBound = True Then
ActiveWorkbook.Close
Windows(ThisFileName).Active
ActiveCell.Offset(0, 1) = "Data_Table"
End If
'Exit For
Else
ActiveWorkbook.Close
'Windows(ThisFileName).Active
'ActiveCell.Offset(0, 1) = "None"
End If
'Exit For
Windows(ThisFileName).Activate
ActiveCell.Offset(1, 0).Range("a1").Select
Loop
End Sub