Function CreateNewFolder(ByVal TmpName As String) As String
Dim Nom_Complet As String
Dim strDrive As String
Sheets("Control").Select
gvSTRPathSave = Sheets("Control").Range("B4").Value & "\"
If Dir(gvSTRPathSave & TmpName & "_" & Format(Date, "dd_mm_yyyy"), vbDirectory) = "" Then
strDrive = Left(gvSTRPathSave, 1)
ChDrive strDrive
ChDir gvSTRPathSave
MkDir "Export" & "_" & Format(Date, "dd_mm_yyyy")
End If
Nom_Complet = gvSTRPathSave & TmpName & "_" & Format(Date, "dd_mm_yyyy") & "\" & TmpName & "_" & Format(Date, "dd_mm_yyyy") & ".xlsm"
ActiveWorkbook.SaveCopyAs Nom_Complet
CreateNewFolder = Nom_Complet
End Function
Sub traitement()
'Traitement des données
Dim Nom_Classeur As String
Dim Fichier As String
'Préparation du classeur final
Nom_Classeur = CreateNewFolder(strTmpName)
Workbooks.Open Filename:=Nom_Classeur
Fichier = ActiveWorkbook.Name
With ActiveWorkbook.Worksheets("BDD")
For j = 2 To Ncol
vntTmpVector = Application.Index(Application.Transpose(gvVNTArrayQueryData), j)
strTmpName = CStr(vntTmpVector(1))
vntTmpVector(1) = Empty
gvVNTCriteriaVector = CreateCriteriaVector(dictReference)
.Range(.Cells(4, 1), .Cells(4, 1).End(xlToRight)).AutoFilter Field:=20, Criteria1:=Array(gvVNTCriteriaVector), Operator:=xlFilterValues
.Range(.Cells(5, 1), .Cells(Nrow + 3, Ncol + 3)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.Range(.Cells(4, 1), .Cells(4, 1).End(xlToRight)).AutoFilter
Application.Calculate
Next j
End With
'Sauvegarde et Ferme le classeur de travail
Workbooks(Fichier).Close True
' Le classeur source reprend la main
End Sub