1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| Public procedureEnCours As Boolean
Public classeurOuvert As String
Public Ouvert As Boolean
'Chemin initial proposé à l'utilisateur quand il ouvre le fichier
Private Const CHEMIN_FICHIERS As String = "D:\DONNEES" 'A PERSONNALISER !
'La liste des choix pour l'utilisateur
Private Const LISTE_DEROULANTE As String = "FRUIT,VIENNOISERIE,VIANDE" 'A PERSONNALISER !
'Première partie de la macro
'Ouverture du fichier, préparation et choix pour l'utilisateur des catégories
Public Sub SuiviCash1()
Dim wbExterne As Workbook
Dim wsExterne As Worksheet
Dim nbLignes As Long
Dim typeObjet As String
Dim rgCorres As Range
Dim i As Long
'Ouverture du fichier
Ouvert = OuvertureFichier(wbExterne, CHEMIN_FICHIERS)
If Ouvert Then
classeurOuvert = wbExterne.Name
Set wsExterne = wbExterne.Worksheets(1)
'Compteur du nombre de ligne à balayer (ie: cellules pleines)
nbLignes = wsExterne.Cells(65536, "C").End(xlUp).Row
'On initialise la table de correspondance
InitialiserTableCorrespondance rgCorres
For i = 6 To nbLignes 'Pour chaque ligne
'On cherche le contenu
wsExterne.Cells(i, 6).Value = TrouverCorrespondance(wsExterne.Cells(i, 3).Value, rgCorres)
Next i
'Autofit des colonnes du fichier ouvert
wsExterne.UsedRange.EntireColumn.AutoFit
'Tri par ordre alphabétique
wsExterne.Range("A6:F" & nbLignes).Sort Key1:=wsExterne.Range("F6"), Order1:=xlAscending, Header:=xlNo
'Création des listes déroulantes
For i = 6 To nbLignes
If wsExterne.Cells(i, 6).Value = "A CLASSER" Then
With wsExterne.Cells(i, 6).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=LISTE_DEROULANTE
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
End If
Next i
End If
End Sub |
Partager