|
下記コードで思う通りの動きになりました。
ご指摘のコード
Set FSO=Nothig
を削除したら上手くゆきました。
有難う御座いました。
Private Sub CommandButton1_Click()
Dim FSO As Object, Folder As Variant
Dim ws As Worksheet
Dim Lst As Variant
Dim i As Integer
Dim FolPath1 As String
Dim FolPath2 As String
Dim CopyFrom As String
Dim CopyTo As String
Set ws = Worksheets("一覧表")
Set FSO = CreateObject("Scripting.FileSystemObject")
FolPath1 = "C:\Users\○△□\Desktop\Aフォルダー"
FolPath2 = "C:\Users\○△□\Desktop\Bフォルダー"
For Each Folder In FSO.GetFolder(FolPath1).SubFolders
For i = 1 To 100
Set Lst = Workbooks(1).Worksheets(1).Cells(i + 1, 1)
If Folder.Path = FolPath1 & "\" & Lst Then
CopyFrom = FSO.BuildPath(FolPath1, Folder.Name)
CopyTo = FSO.BuildPath(FolPath2, Folder.Name)
FSO.CopyFolder CopyFrom, CopyTo
End If
Next i
Next Folder
End Sub
|
|