snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub CopyAllFileInfolder()
Dim FileSystem As Object
Dim HostFolder As String
HostFolder = Sheets("Cdir").Range("B3").Value
Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)
End Sub
Sub DoFolder(Folder)
Dim SubFolder
For Each SubFolder In Folder.SubFolders
DoFolder SubFolder
Next
Dim File
For Each File In Folder.Files
'MsgBox File
FileCopy File, "C:\Users\Pitheerap\Desktop\Upload SQL\Folder1\" & VBA.Split(File, "\")(UBound(VBA.Split(File, "\")))
Next
End Sub
You do not have the required permissions to view the files attached to this post.
'Other code
For Each File In Folder.Files
'MsgBox File
If InStr(File, "\CRR") Then
FileCopy File, "C:\Users\Pitheerap\Desktop\Upload SQL\Folder1\" & VBA.Split(File, "\")(UBound(VBA.Split(File, "\")))
End If
Next
'Other code
'Other code
For Each File In Folder.Files
'MsgBox File
If InStr(File, "\CRR") Then
FileCopy File, "C:\Users\Pitheerap\Desktop\Upload SQL\Folder1\" & VBA.Split(File, "\")(UBound(VBA.Split(File, "\")))
End If
Next
'Other code