Private Sub CommandButton1_Click()
'################################################# ################################################## #############
' GENERATION NOUVEAU CLASSEUR
'################################################# ################################################## #############
'
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Call RépertoireExiste("J:\agent\" & ComboBox1.Value)
Call RépertoireExiste("J:\agent\" & ComboBox1.Value & "\" & ComboBox2.Value)
'On créer l'objet Excel
Set xlApp = CreateObject("Excel.Application")
'On défini le nombre d'onglets (ici 7)
xlApp.SheetsInNewWorkbook = 7
'On ajoute un classeur
Set xlBook = xlApp.Workbooks.Add
'On donne un nom au classeur
xlBook.SaveAs ("J:\agent\" & ComboBox1.Value & "\" & ComboBox2.Value & "\" & ComboBox3.Value & " Feuille suivi VH")
'On rend le classeur visible **(Modif NQC)**
xlApp.Visible = False
'Modif NQC
For i = 1 To 7
Set xlSheet = xlBook.Worksheets(i)
xlSheet.Name = "Cycle " & i
Next
Set xlSheet = Nothing
'On remet la propriété de l'application à 3 (par défaut)
xlApp.SheetsInNewWorkbook = 3
Set f = xlBook.Worksheets("BD_saison") '**Modif NQC : ajout xlBook. **
Set g = xlBook.Worksheets("BD_agents")
Set h = xlBook.Worksheets("BD_centres")
n = WorksheetFunction.CountA(f.Columns(1))
m = WorksheetFunction.CountA(g.Columns(1))
o = WorksheetFunction.CountA(h.Columns(1))
'################################################# ################################################## #############
' REMPLISSAGE DU NOUVEAU CLASSEUR
'################################################# ################################################## #############
For i = 1 To m
If ComboBox3.Value = g.Cells(i, 2) & " " & g.Cells(i, 3) Then
For j = 1 To o
If h.Cells(j, 4) = g.Cells(i, 1) Then
team = h.Cells(j, 3)
End If
Next j
End If
Next i
xlApp.Visible = True