nguoinoixa_2006
Thành viên mới

- Tham gia
- 19/10/10
- Bài viết
- 4
- Được thích
- 0
Chào Admin và các bạn trên diễn đàn, mình nhờ các bạn sửa đoạn code này được không ạ.
Thư mục chứa file: chứa tất cả file cần copy.
Sub của mình sưu tầm:
Private Function CountFiles()
strDirectory = "I:\Thư mục chứa file"
strDestFolder = "Thư mục đến"
strExt = "pdf"
Dim myfilesystemobject As Object
Dim myfiles As Object
Dim myfile As Object
Dim rng As Range
Set rng = ThisWorkbook.ActiveSheet.Range("A1:A49")
Set myfilesystemobject = CreateObject("Scripting.FileSystemObject")
Set myfiles = myfilesystemobject.GetFolder(strDirectory).Files
For Each cell In rng
For Each myfile In myfiles
If Not IsNull(cell.Value) Then
If myfile = strDirectory & "\" & cell.Value Then
With myfile
.Copy strDestFolder & "\" & myfile.Name
End With
Else
End If
End If
Next myfile
Next cell
End Function
Thư mục chứa file: chứa tất cả file cần copy.
Sub của mình sưu tầm:
Private Function CountFiles()
strDirectory = "I:\Thư mục chứa file"
strDestFolder = "Thư mục đến"
strExt = "pdf"
Dim myfilesystemobject As Object
Dim myfiles As Object
Dim myfile As Object
Dim rng As Range
Set rng = ThisWorkbook.ActiveSheet.Range("A1:A49")
Set myfilesystemobject = CreateObject("Scripting.FileSystemObject")
Set myfiles = myfilesystemobject.GetFolder(strDirectory).Files
For Each cell In rng
For Each myfile In myfiles
If Not IsNull(cell.Value) Then
If myfile = strDirectory & "\" & cell.Value Then
With myfile
.Copy strDestFolder & "\" & myfile.Name
End With
Else
End If
End If
Next myfile
Next cell
End Function
Lần chỉnh sửa cuối: