Bonjour,
Je travail en entreprise sur une interface Excel qui gère le nettoyage des machines.
Toutes les données de chaque machine sont transmises vers une base de données Excel.
Dans mon fichier ci-dessous, je n'arrive pas à faire varier les lignes en rouge en fonction de la variable : fichier (L'indice de correspond pas à la sélection)
Fichier étant le nom de la machine où se trouve l'interface.
Merci d'avance pour votre aide.
Cordialement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Sub basededonnees() fichier = Sheets("liste").Cells(1, 1) Application.ScreenUpdating = False Workbooks.Open Filename:="G:\Gestion autonome\Basesdedonnees\base_de_donnees_gestion_autonome.xlsx" Windows("base_de_donnees_gestion_autonome.xlsx").Activate Sheets("baseddcoupe").Select h = Cells(1, 1).End(xlDown).Row h = h + 1 For lig = 8 To 40 If Workbooks("Gestion_Autonome_ " & fichier & ".xlsm").Sheets("Tâche").Cells(lig, 3) <> "" Then Cells(h, 1) = "Hegla5" Cells(h, 2) = Date datevb = Date Cells(h, 3) = Year(datevb) Cells(h, 4) = Month(datevb) Cells(h, 5) = Format(datevb, "ww", vbMonday, vbFirstFourDays) Cells(h, 6) = Ini Cells(h, 7) = Horaire For i = 1 To 4 Cells(h, 7 + i) = Workbooks("Gestion_Autonome_ " & fichier & ".xlsm").Sheets("tâche").Cells(lig, i) Next i Cells(h, 12) = "DP" Cells(h, 13) = 0 Cells(h, 14) = 0 h = h + 1 End If Next lig Windows("base_de_donnees_gestion_autonome.xlsx").Close True Application.ScreenUpdating = True End sub
Partager