Bonjour,

J'ai une macro qui ouvre un fichier excel dans lequel il y a 5 onglets (Lundi à Vendredi) dans ces onglets il peut y avoir des informations. Si la cellule A10 de l'onglet est vide alors on passe au suivant sinon on copie toutes les lignes allant de A10 jusqu'à A30 pour lesquelles Ai est non vide.

Bon j'ai fait ce code mais il plante sur le 1er next onglet
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Sub Importer_les_données()
 
Dim onglet As Worksheet
 
 
For Each onglet In Application.ActiveWorkbook.Worksheets
 
dossier = "C:\Bordereau de visites"
 
 
Sheets("Recherche").Select
 
date_visite = Range("E14")
Rep = Range("L1")
representant = Range("E1")
semaine_annee = "S" & Range("F1") & "_" & Range("G1")
 
monfichier = Dir(dossier & "\Bordereau_" & Rep & "_" & semaine_annee & ".xls")
fichier = (dossier & "\Bordereau_" & Rep & "_" & semaine_annee & ".xls")
 
 
 
Workbooks.OpenText Filename:=fichier
 
For i = 10 To 30
   If IsEmpty(Range("A10")) Then
        Next onglet
 
   Else
 
   Range("A10").Select
        ActiveCell.Offset(rowOffset:=0, columnOffset:=10).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range(Selection, Selection.End(xlDown)).Select
 
        Selection.Copy
 
 
        Windows("Recherche_Bordereaux.xls").Activate
        Sheets("Bordereau de visites").Select
        ActiveSheet.Paste
 
        Copie_Date
   End If
 
Next i
Next onglet
 
 
 
 
End Sub
Qq1 peut-il m'aider ?

Merci par avance

Nini