Sub MAJ_Mois()
'se lance par les touches Ctrl+M
If MsgBox("Etes-vous sûr qu'il faut mettre à jour les mois ?", vbYesNo + vbQuestion) = vbNo Then Exit Sub
Dim source$, w As Worksheet, c As Range, c1 As Range
source = ThisWorkbook.Path & "\Classeur1.xlsx" 'à adapter
Application.ScreenUpdating = False
Application.DisplayAlerts = False 'si le fichier est déjà ouvert
With Workbooks.Open(source).Sheets(1)
For Each w In ThisWorkbook.Worksheets
Set c = .Cells.Find(Replace(w.Name, " ", "*") & "*", , xlValues, xlWhole)
If Not c Is Nothing Then
Set c1 = w.Cells.Find("Qté N")
If Not c1 Is Nothing Then c1(1, 2).Resize(, 12) = c(2, 2).Resize(, 12).Value
Set c1 = w.Cells.Find("C A N")
If Not c1 Is Nothing Then c1(1, 2).Resize(, 12) = c(3, 2).Resize(, 12).Value
End If
Next
.Parent.Close True
End With
End Sub
Sub Nouvelle_Annee()
If MsgBox("Etes-vous sûr qu'il faut créer une nouvelle année ?", vbYesNo + vbQuestion) = vbNo Then Exit Sub
Dim source$, w As Worksheet, c As Range, c1 As Range, n%, c2 As Range
source = ThisWorkbook.Path & "\Classeur1.xlsx" 'à adapter
Application.ScreenUpdating = False
Application.DisplayAlerts = False 'si le fichier est déjà ouvert
With Workbooks.Open(source).Sheets(1)
Set c = .Cells.Find("FamilleArticle", , xlValues, xlWhole)
If Not c Is Nothing Then
For Each w In ThisWorkbook.Worksheets
Set c1 = w.Cells.Find("FamilleArticle")
If Not c1 Is Nothing Then
n = n + 1
If n = 1 Then If Year(c(1, 3)) = Year(c1(1, 2)) Then MsgBox "Modifiez l'année du fichier source !", 48: Exit Sub
w.Cells.Find("FamilleArticle", c1)(1, 2).Resize(, 12) = c1(1, 2).Resize(, 12).Value
c1(1, 2).Resize(, 12) = c(1, 3).Resize(, 12).Value
End If
Set c1 = w.Cells.Find("Qté N")
If Not c1 Is Nothing Then
Set c2 = w.Cells.Find("Qté N*-*")
If Not c2 Is Nothing Then c2(1, 2).Resize(, 12) = c1(1, 2).Resize(, 12).Value
c1(1, 2).Resize(, 12).ClearContents
End If
Set c1 = w.Cells.Find("C A N")
If Not c1 Is Nothing Then
Set c2 = w.Cells.Find("C A N*-*")
If Not c2 Is Nothing Then c2(1, 2).Resize(, 12) = c1(1, 2).Resize(, 12).Value
c1(1, 2).Resize(, 12).ClearContents
End If
Next
End If
.Parent.Close True
End With
End Sub