Maj 2018 formula
Bonjour, à tous je travail actuellement sur la mise à jour d'un fichier rapatriant des données pour faire un tableau de bord.
Tous fonctionnais au miel en 2017, j'ai donc changer les quelques formule pour 2018, mais cela ne fonctionne plus alors que je n'ai pas touché vraiment au code ci dessous:
Le code suivant va inscrire des formules dans le tableau de stocks qui va chercher les info sur le fichier
'renseigné par les équipes, comme le chemin et le nom du fichier des stocks sont variables, la formule inscrite dans
'les cellules vont varier en fonction de la date. Elle même décomposée pour former le "Chemin" et "Fichier"
Sub stocks()
'Rends visible les onglets suivants :
Sheets("Stocks").Visible = True
Sheets("S3C").Visible = True
Sheets("TTF").Visible = True
Sheets("Orga").Visible = True
Sheets("Qualité").Visible = True
Sheets("Transport").Visible = True
Sheets("Maintenance").Visible = True
Sheets("LOG").Visible = True
Sheets("Trafic").Visible = True
Sheets("Plan Prod").Visible = True
Sheets("Stocks").Select
'pour le PF
Chemin = [M2]
Fichier = [L2]
If Dir(Chemin & "\" & Fichier) <> "" Then
[B10].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!H18"
[B11].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!K18"
[B12].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!N18"
[B13].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!Q18"
[B14].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!E30"
[B15].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!H30"
[C10].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!H22"
[C11].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!K22"
[C12].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!N22"
[C13].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!Q22"
[C14].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!E32"
[C15].Formula = "='" & Chemin & "\[" & Fichier & "]PF 07h00 '!H32"
'pour le GF
Chemin1 = [M3]
Fichier1 = [L3]
[F10].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!K27"
[F11].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!O27"
[F12].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!S27"
[F13].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!W27"
[F14].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!G36"
[F15].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!G40"
[H16].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!S41"
[G10].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!K26"
[G11].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!O26"
[G12].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!S26"
[G13].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!W26"
[G14].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!G39"
[G15].Formula = "='" & Chemin1 & "\[" & Fichier1 & "]07h00 '!G41"
'pour les KUB
Chemin2 = [M4]
Fichier2 = [L4]
[K10].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!E13"
[K11].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!G13"
[K12].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!I13"
[K13].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!K13"
[K14].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!M13"
[L10].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!E15"
[L11].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!G15"
[L12].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!I15"
[L13].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!K15"
[L14].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!M15"
[K15].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!Q16"
[L16].Formula = "='" & Chemin2 & "\[" & Fichier2 & "]LOG 6H'!Q17"
Else
MsgBox "Fichier inconnu!"
End If
'Masque les onglets suivants :
Sheets("Stocks").Visible = False
Sheets("S3C").Visible = False
Sheets("TTF").Visible = False
Sheets("Orga").Visible = False
Sheets("Qualité").Visible = False
Sheets("Transport").Visible = False
Sheets("Maintenance").Visible = False
Sheets("LOG").Visible = False
Sheets("Trafic").Visible = False
Sheets("Plan Prod").Visible = False
Sheets("Tdb").Select
End Sub
j'ai donc mon fameux "Fichier inconnu qui apparait
j'ai vérifier les chemin du réseau et les noms des fichiers
Idem pour les case de réf de la macro (M2;L2-M3;L3;M4-L4)
une idée ?
- Messages
- 2'415
- Excel
- 2019
- Inscrit
- 13/07/2017
- Emploi
- Formateur, animateur,tech.informatique
Bonjour
à tout hasard
Sheets("Tdb").Select (à la fin du code) est-elle activé au début ou désactiver en fermant le classeur ?
crdlt,
André
Bonjour, et merci de vous intéresser au sujet.
Oui c'est justement l'onglet qui fait office de tableau de bord. L'onglet TBD est toujours activé , jamais masqué.
Ce que je ne comprend pas c'est que j'ai d'autre ligne de code concu exactement de la même manière qui fonctionne très bien, pour d'autre onglets.
exemple:
ub Total_J()
'Rapatrie les données du rapport RT
Sheets("Total_J").Visible = True
Sheets("Total_J").Select
Chemin = [N2]
Fichier = [M2]
If Dir(Chemin & "\" & Fichier) <> "" Then
[B3].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!D61"
[B5].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!B21"
[B8].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!B54"
[B9].Formula = "='" & Chemin & "\[" & Fichier & "]Nuit '!D29"
[F7].Formula = "='" & Chemin & "\[" & Fichier & "]Nuit '!G33"
[D5].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!B11"
[E5].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!B13"
[D5].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!C11"
[E5].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!C13"
[B10].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!B44"
[B11].Formula = "='" & Chemin & "\[" & Fichier & "]Jour '!B31"
[F6].Formula = "='" & Chemin & "\[" & Fichier & "]Nuit '!F29"
Else
MsgBox "Fichier inconnu!"
End If
Sheets("Total_J").Visible = False
Sheets("Tdb").Select
End Sub
Du coup cela ne serait pas un problème de liaison de fichier ?
Car lorsque que je remplace manuellement la Formule les bon chiffre s'affiche exemple ci dessous :
='U:\PUBLIC\Production\GR\STOCKS\STOCKS 2018\JANVIER\PF\[090118 PF.xls]PF 07h00 '!H18
='U:\PUBLIC\Production\GR\STOCKS\STOCKS 2018\JANVIER\PF\[050118 PF.xls]PF 07h00 '!H18
Du coup je ne comprend pas d’où vient le problème d'autant que les case réf sont à la bonne date concernant "Fichier" et "Chemin"
Cordialement, Lybelo
Re: Sujet résolu
Au final j'ai trouvé mon erreur... (honte de le dire)
Dans mes cases M2 M3 M4 ou je nomme mes chemin j'ai fait une erreur dans le chemin. Voila pourquoi la macro passait directement à la condition Else.
C'est un simple problème de lecture du Chemin sur le Réseau .... j'ai rajouter un "\" et 2018 en trop.
- Messages
- 2'415
- Excel
- 2019
- Inscrit
- 13/07/2017
- Emploi
- Formateur, animateur,tech.informatique
Bien joué ^^
j'avais pensé aux apostrophes mais c'est super si tu as trouvé cool
bonne journée