snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub TestFolder()
Dim tPath As String
Dim r As Range
Dim sPath As String
On Error Resume Next
tPath = "C:\Legacy\A\Package issued\PP\" '<== Target path
If Dir(tPath, vbDirectory) = vbNullString Then
MkDir "C:\Legacy\"
MkDir "C:\Legacy\A\"
MkDir "C:\Legacy\A\Package issued\"
MkDir "C:\Legacy\A\Package issued\pp\"
End If
sPath = "C:\" '<== Source path
For Each r In Sheets("line list index").Range("E2:E33")
FileCopy sPath & r & ".PDF", tPath & r & ".PDF"
Next r
End Sub
Dim tPath As String
Dim r As Range
Dim s As Range
Dim sPath As String
On Error Resume Next
tPath = "C:\Legacy\B\Package issued\PP\" '<== Target path
If Dir(tPath, vbDirectory) = vbNullString Then
MkDir "C:\Legacy\"
MkDir "C:\Legacy\B\"
MkDir "C:\Legacy\B\Package issued\"
MkDir "C:\Legacy\B\Package issued\pp\"
End If
tPath = "C:\Legacy\B\Package issued\PP\"
For Each s In Sheets("line list index").Range("h2:h33")
MkDir tPath & s ' ChDir "C:\Legacy\b\Package issued\pp\"
Next s
sPath = "C:\Legacy\Marked up\P&ID\Copy of Piping EMC\" '<== Source path
For Each r In Sheets("line list index").Range("e2:ee")
FileCopy sPath & r, tPath & r
Next r
End Sub
You do not have the required permissions to view the files attached to this post.
sPath = "C:\Legacy\Marked up\P&ID\Copy of Piping EMC\" '<== Source path
For Each r In Sheets("line list index").Range("e2:ee")
FileCopy sPath & r, tPath & r
Next r
Sub Button62_Click()
Dim tPath As String
Dim s As Range
Dim sPath As String
On Error Resume Next
tPath = "C:\Legacy\B\Package issued\PP\" '<== Target path
If Dir(tPath, vbDirectory) = vbNullString Then
MkDir "C:\Legacy\"
MkDir "C:\Legacy\B\"
MkDir "C:\Legacy\B\Package issued\"
MkDir "C:\Legacy\B\Package issued\pp\"
End If
sPath = "C:\Legacy\Marked up\P&ID\Copy of Piping EMC\" '<== Source path
For Each s In Sheets("line list index").Range("h2:h33")
MkDir tPath & s
FileCopy sPath & s.Offset(0, -3), tPath & s & s.Offset(0, -3)
Next s
End Sub
Sub Button2_Click()
Dim tPath As String
Dim s As Range
Dim sPath As String
On Error Resume Next
sPath = "D:\New Folder\" '<== Source path
tPath = "C:\Legacy\B\Package issued\PP\" '<== Target path
For Each s In Sheets("Sheet1").Range("I2:I250")
If Dir(tPath & s, vbDirectory) = vbNullString Then
MkDir "C:\Legacy\"
MkDir "C:\Legacy\B\"
MkDir "C:\Legacy\B\Package issued\"
MkDir "C:\Legacy\B\Package issued\pp\"
MkDir "C:\Legacy\B\Package issued\pp\" & s
End If
FileCopy sPath & s.Offset(0, -3), tPath & s & "\" & s.Offset(0, -3)
Next s
End Sub