salut
je chercher a naviguer dans tous les fichiers excells d'un répertoire
et dans chaque fichier excelle parcourir toute les worksheet afin de récupérer des valeurs à certain endroit...
je vois bien les fichiers excell s'ouvrir... mais je passe vois en tous qu'un seul msgBox... donc la boucle n'a pas lieu...
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 Sub BrowseFolders() LoopThruExcelFiles ("C:\all") End Sub Function LoopThruExcelFiles(FileDir As String) As String Dim lCount As Long Dim wbResults As Workbook Dim wbCodeBook As Workbook Dim FileName As String Application.ScreenUpdating = False Application.DisplayAlerts = True Application.EnableEvents = True On Error Resume Next DoEvents Set wbCodeBook = ThisWorkbook With Application.FileSearch .NewSearch 'Change path to suit .LookIn = FileDir .FileType = msoFileTypeExcelWorkbooks If .Execute > 0 Then 'Workbooks in folder For lCount = 1 To .FoundFiles.Count ' Loop through all. Workbooks.Open FileName:=.FoundFiles(lCount) FileName = ActiveWorkbook.Name wbCodeBook.Activate extractData wbCodeBook.Worksheets Windows(FileName).Close Next lCount End If End With Application.ScreenUpdating = True Application.DisplayAlerts = True Application.EnableEvents = True End Function Sub extractData(allWs) Dim ws As Worksheet For Each ws In allWs msgBox ws.Nam Next ws end Sub
une idée?
Partager