Bonjour,
J'ai un classeur central qui ouvre différent classeurs excel et j'aimerais copier de ce classeur central deux cellules dans chaque classeur excel qu'il ouvre (dans deux onglets). J'ai fais le plus dur à savoir ouvrir chaque classeurs...
J'ai souligné la ou il y avait un soucis...
Merci beaucoup pour votre aide
Code :
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
32
33
34
35 Option Explicit Sub Test() Dim Plage As Range, InpRng As Range Dim Cel As Range 'On Error GoTo Err_Read Dim Derl As Long Derl = ThisWorkbook.Worksheets("Mensuel").Range("A" & Cells.Rows.Count).End(xlUp).Row Set InpRng = ThisWorkbook.Worksheets("Mensuel").Range("A2:A" & Derl) Debug.Print InpRng.Address, InpRng.Cells.Count For Each Cel In InpRng If Trim("" & Cel) <> "" Then Histo CStr(Cel) Else MsgBox Cel.Address & " invalide" Next End Sub Sub Histo(Fichier As String) Dim Sh As Worksheet Dim wb As Workbook Application.DisplayAlerts = False Set wb = Workbooks.Open(Fichier) Application.DisplayAlerts = True For Each Sh In wb.Sheets TraitementSheet Sh Next wb.Save wb.Close End Sub Sub TraitementSheet(Sh As Worksheet) Dim Plage As Range Dim Cel As Range Sh.Range("D1:D2").ThisWorkbook.Worksheets.Copy Destination:=Sh.Valorisation and Sh.Histo Range.Activate("B3:B4") End Sub
Partager