|
- Sub myFind(sh As Worksheet, sht As Worksheet)
- Dim rg As Range, s As String, n As Long
- Set rg = Range("a:f").Find("xls", LookIn:=xlFormulas)
- If Not rg Is Nothing Then
- s = rg.Address
- Do
- Debug.Print rg.Address
- n = sht.Cells(sht.Rows.Count, 1).End(xlUp).Row + 1
- sht.Cells(n, 1) = "'" & rg.Formula
- sht.Cells(n, 2) = rg.Address(0, 0)
- Set rg = Range("a:f").FindNext(rg)
- Loop While Not rg Is Nothing And rg.Address <> s
- End If
- End Sub
- Sub folder_dialog()
- Dim folder_path As String
- Application.ScreenUpdating = False
- With Application.FileDialog(msoFileDialogFolderPicker)
- .InitialFileName = ThisWorkbook.Path & ""
- If .Show = -1 Then
- folder_path = .SelectedItems(1) & ""
- Debug.Print folder_path
- foreach_folder folder_path
- End If
- End With
- Application.ScreenUpdating = True
- End Sub
- Sub foreach_folder(folder_p As String)
- Dim wk As Workbook, ss As Worksheet, ac As Worksheet
- Dim st As String ', a As Integer
- Set ac = ActiveSheet
- st = Dir(folder_p & "*.xls*")
- Application.ScreenUpdating = False
- Do While st <> ""
- Set wk = Workbooks.Open(folder_p & st)
- For Each ss In wk.Worksheets
- myFind ss, ac
- Next ss
- wk.Close False
- Debug.Print st
- st = Dir
- Loop
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|