|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Public k, kxm, txm, dxm
- Sub main()
- Dim fp As String, Arr, i&, Myr&
- Dim Sht As Worksheet, sh As Worksheet, dic
- Set dic = CreateObject("Scripting.Dictionary")
- Set dxm = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- fp = ThisWorkbook.Path & ""
- Call searfile(fp, ".jpg")
- Set Sht = ActiveSheet
- Myr = Sheet2.[d65536].End(xlUp).Row
- Arr = Sheet2.Range("d1:d" & Myr)
- For i = 2 To UBound(Arr)
- dic(Arr(i, 1)) = ""
- Next
- k = dic.keys
- Application.ScreenUpdating = True
- End Sub
- Sub searfile(fp As String, fkey As String)
- Dim Arr1() As String, i1 As Integer, i2 As Integer, fm, aa, xm$, nm$
- If Right(fp, 1) <> "" Then fp = fp & ""
- If Len(fkey) < 1 Then fkey = ".xls"
- fm = Dir(fp, vbDirectory)
- Do While fm <> ""
- If fm <> "." And fm <> ".." Then
- If (GetAttr(fp & fm) And vbDirectory) = vbDirectory Then
- i1 = i1 + 1
- ReDim Preserve Arr1(1 To i1)
- Arr1(i1) = fp & fm
- End If
- If Right(fm, 4) = fkey Then
- aa = Split(fp, "")
- xm = aa(UBound(aa) - 1)
- nm = Split(fm, ".")(0)
- dxm(xm) = dxm(xm) & nm & ","
- Else
- dxm(fm) = ""
- End If
- End If
- fm = Dir
- Loop
- For i2 = 1 To i1
- Call searfile(Arr1(i2), fkey)
- Next
- kxm = dxm.keys: txm = dxm.items
- End Sub
复制代码 |
|