No.2ベストアンサー
- 回答日時:
こんばんは。
If f.Attributes < 1024 Then '特別なフォルダは除外
これだけで済むかは不明
'//
Option Explicit
Private myRange As Range
Private FSO As Object
Private Const DST As String = "C:\X\" '末尾には¥を入れる
Sub FindAndCopy1()
Const mPath = "C:\Z\" '末尾には¥を入れる
Set myRange = Range("A2", Cells(Rows.Count, 1).End(xlUp)) 'A列
Set FSO = CreateObject("Scripting.FileSystemObject")
FileSearchN mPath
Set FSO = Nothing
End Sub
Sub FileSearchN(Path As String)
Dim buf As Variant
Dim f As Object
Dim ret As Variant
buf = Dir(Path & "\*.pdf") '拡張子
Do While buf <> ""
ret = Application.Match(buf, myRange, 0)
If IsNumeric(ret) Then
If Not FSO.FileExists(DST & buf) Then
FSO.CopyFile Path & "\" & buf, DST
End If
End If
buf = Dir()
DoEvents
Loop
With FSO
For Each f In .GetFolder(Path).SubFolders
If f.Attributes < 1024 Then '特別なフォルダは除外
Call FileSearchN(f.Path)
End If
DoEvents
Next f
End With
End Sub
No.1
- 回答日時:
以下が参考になると思います
ファイル検索の処理速度をUPさせるには?
http://www.moug.net/faq/viewtopic.php?t=70650
moug は6ヶ月でQAは消えるみたいなので・・・
※ 前回のご質問
VBAを使用した保存方法
http://oshiete.goo.ne.jp/qa/8961276.html
急いでいた?
問題が解決できたのか、わかりませんが
回答した側にとっては、役に立ったのかくらいは知りたいものです。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
Windows10でコマンドプロンプト...
-
フォルダを開いて、閉じるのプ...
-
【マクロ】ファイル名の日付に...
-
ファイル名と同名のフォルダを...
-
フォルダのサイズを取得したい
-
【VBS】古い日付のフォルダを削...
-
デスクトップの画像をhtmlに表...
-
VB.NETでツリービューにフォル...
-
vbsで選択ダイアログを表示した...
-
DIR関数
-
会社のネットワーク上のファイ...
-
クラウドにあるフォルダを共有...
-
集めたシートのシート名を変更...
-
エクセル マクロで指定フォル...
-
エクセルのマクロコードの一部...
-
FileSystemObjectでのパス名の取得
-
VBA フォルダの複数選択ができない
-
VB6.0 FileListBoxでフォルダ表示
-
VBAでファイル名を指定して保存...
-
Excel VBA マクロ フォルダ名を...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
Windows10でコマンドプロンプト...
-
VBA 最新のフォルダ取得
-
ファイル名と同名のフォルダを...
-
デスクトップの画像をhtmlに表...
-
Excelのハイパーリンクについて...
-
VBプロジェクトでのフォルダ構...
-
会社のネットワーク上のファイ...
-
【マクロ】ファイル名の日付に...
-
パス名に2バイト文字(マルチバ...
-
Access VBA で フォルダ権限...
-
カレントフォルダって?
-
VBA フォルダ名に特定の文字を...
-
ExcelVBAでフォルダへのハイパ...
-
C ファイル出力で、フォルダが...
-
excelマクロ 冒頭3文字が一致す...
-
保存先のフォルダ名を指定した...
-
マクロVBAのフォルダ階層別で検...
-
Excelで指定したフォルダに保存...
-
ディレクトリ名変更してコピー...
-
vbsで選択ダイアログを表示した...
おすすめ情報