Hi and thanks for the response again. I am running them all from the same folder as instructed, with the ToolBox.xls file. It starts to process the files and then stops with the type mismatch error. Code below
Option Explicit
Sub Treat()
Dim DelRg As Range
Dim FR As Integer, LR As Integer, I As Integer
Dim WkSh As String
Dim WS As Worksheet
Dim WkCol As String
WkSh = "March,April,May,June,July,August,September,October,November"
WkCol = "BR"
FR = 13
LR = 350
For Each WS In Worksheets
If (WkSh Like "*" & WS.Name & "*") Then
With WS
Set DelRg = .Cells(LR + 1, 1)
For I = FR To LR
If .Cells(I, WkCol) = 0 Then Set DelRg = Union(DelRg, .Cells(I, 1))
Next
End With
DelRg.EntireRow.Delete
End If
Next
End Sub
Sub TreatAllFile()
Dim Masq_File As String
Dim DIR_Result As String
Dim StartRow As Integer
Dim I As Integer
Dim ThisFileName As String
Dim WkPath As String
Dim WkStg As String
Dim DispCol As String
Application.ScreenUpdating = False
'----- INIT
WkPath = ActiveWorkbook.Path
ThisFileName = ActiveWorkbook.Name
StartRow = 5
DispCol = "B"
' Range("WkPath") = WkPath
Range(Cells(StartRow, DispCol), Cells(Rows.Count, DispCol).End(xlUp)).ClearContents
'------------ LOOK IF EXISTS SOME FILES
Masq_File = WkPath & "\*.*"
DIR_Result = Dir(Masq_File, 0) ' 0 --> READ ONLY FILES
While (DIR_Result <> "")
If (DIR_Result <> ThisFileName) Then
Cells(StartRow + I, DispCol) = DIR_Result
WkStg = WkPath & "\" & DIR_Result
Workbooks.Open Filename:=WkStg
Application.Run ThisFileName & "!Treat"
ActiveWindow.Close SaveChanges:=True ' QUIT WITH save
End If
I = I + 1
DIR_Result = Dir
Wend
Application.ScreenUpdating = True
End Sub
would you like me to post a file that has been treated OK and also one that is failing to run?
Bookmarks