LoginSignup
2
1

More than 5 years have passed since last update.

EXCEL VBA カレントフォルダ内ファイル名一覧

Last updated at Posted at 2019-02-08

シートに書き出す

Sub カレントフォルダ内ファイル名一覧()
    Dim cnt As Long
    Dim path As String
    Dim buf As String

    cnt = 0
    path = ThisWorkbook.path
    buf = Dir(path & "\*")  '"*xlsx"拡張子指定もできる

    Do While buf <> ""
        cnt = cnt + 1
        Cells(cnt, 1) = cnt
        Cells(cnt, 2) = buf
        buf = Dir()
    Loop
End Sub

イミディエイトウインドウに書き出す

Sub カレントフォルダ内ファイル名一覧dp()
    Dim path As String
    Dim buf As String

    path = ThisWorkbook.path
    buf = Dir(path & "\*")  '"*xlsx"拡張子指定もできる

    Do While buf <> ""
        Debug.Print buf
        buf = Dir()
    Loop
End Sub
2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1