|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub qs() '2024/7/2取同一目录下工作薄单位名
Dim fso As Object, folderPath As String, fileName As String, file As Object
Dim rw
Set fso = CreateObject("Scripting.FileSystemObject")
folderPath = ThisWorkbook.Path & "\"
Set ws = ActiveSheet
rw = 1
For Each file In fso.GetFolder(folderPath).Files
If InStr(file, ThisWorkbook.Name) = 0 Then
rw = rw + 1
x = Mid(file, VBA.InStrRev(file, "\") + 1, Len(file) - InStrRev(file, "\") - 4)
ws.Cells(rw, 1).Value = Mid(x, InStrRev(x, "-") + 1)
End If
Next file
Set fso = Nothing: Set file = Nothing
MsgBox "完成"
End Sub
|
|