OVH Cloud OVH Cloud

Ereur de liaison

1 réponse
Avatar
mboileau
Salut

J'ai cette macro dans un fichier excel mais la partie Format(Month(Now)
- 1... ne fonctionne pas. Elle me renvoie Confirm_janv alors que je
voudrais avoir Confirm_juin puisque nous sommes au mois de juillet
maintenant.

Que dois-je faire?

Private Sub Workbook_Open()
p = "C:\Documents and Settings\boilma\Mes documents\Demande de
confirmation - Taux de change"
f = "Confirm_" & Format(Month(Now) - 1, "mmm") & ".xls"
s = "Feuil1"
Application.ScreenUpdating = False
Application.DisplayAlerts = True

With Worksheets("Feuille de travail sem.1").Range("B39")
.Formula = "='" & p & "\[" & f & "]" & s & "'!C11"
End With

With Worksheets("Feuille de travail sem.1").Range("B41")
.Formula = "='" & p & "\[" & f & "]" & s & "'!E11"
End With

With Worksheets("Feuille de travail sem.1").Range("B40")
.Formula = "='" & p & "\[" & f & "]" & s & "'!G11"
End With

With Worksheets("Feuille de travail sem.1").Range("B43")
.Formula = "='" & p & "\[" & f & "]" & s & "'!I16"
End With

Application.ScreenUpdating = True

End Sub

Merci beaucoup
MP

1 réponse

Avatar
Nicolas B.
Salut,

Il faut appliquer le format à une date, pas à un numéro de mois :

Format(Now - Day(Now), "mmm")


A+
Nicolas B.

Salut

J'ai cette macro dans un fichier excel mais la partie Format(Month(Now)
- 1... ne fonctionne pas. Elle me renvoie Confirm_janv alors que je
voudrais avoir Confirm_juin puisque nous sommes au mois de juillet
maintenant.

Que dois-je faire?

Private Sub Workbook_Open()
p = "C:Documents and SettingsboilmaMes documentsDemande de
confirmation - Taux de change"
f = "Confirm_" & Format(Month(Now) - 1, "mmm") & ".xls"
s = "Feuil1"
Application.ScreenUpdating = False
Application.DisplayAlerts = True

With Worksheets("Feuille de travail sem.1").Range("B39")
.Formula = "='" & p & "[" & f & "]" & s & "'!C11"
End With

With Worksheets("Feuille de travail sem.1").Range("B41")
.Formula = "='" & p & "[" & f & "]" & s & "'!E11"
End With

With Worksheets("Feuille de travail sem.1").Range("B40")
.Formula = "='" & p & "[" & f & "]" & s & "'!G11"
End With

With Worksheets("Feuille de travail sem.1").Range("B43")
.Formula = "='" & p & "[" & f & "]" & s & "'!I16"
End With

Application.ScreenUpdating = True

End Sub

Merci beaucoup
MP