EXCEL TOOLS
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
[code]
และปิดด้วย [/code]
ตัวอย่างเช่น [code]dim r as range[/code]
เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)Code: Select all
Sub test()
Dim wb As Variant
Dim source As Range
If Worksheets("PalDying").Range("B6").Value = "" Then End
i = Worksheets("Dyreport").Range("A6:A23").Find(Range("D6"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("A4:R4").Copy
Worksheets("Dyreport").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B6").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B6"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B6:U6").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
i = Worksheets("Report").Range("A:A").Find(Range("B6"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B6:U6").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B7").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B7"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B7:U7").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B7").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B7"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B7:U7").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B8").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B8"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B8:U8").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B8").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B8"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B8:U8").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B9").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B9"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B9:U9").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B9").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B9"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B9:U9").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B10").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B10"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B10:U10").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B10").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B10"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B10:U10").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B11").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B11"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B11:U11").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B11").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B11"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B11:U11").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B12").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B12"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B12:U12").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B12").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B12"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B12:U12").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B13").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B13"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B13:U13").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B13").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B13"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B13:U13").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B14").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B14"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B14:U14").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B14").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B14"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B14:U14").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B15").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B15"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B15:U15").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B15").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B15"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B15:U15").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B16").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B16"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B16:U16").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B16").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B16"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B16:U16").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B17").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B17"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B17:U17").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B17").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B17"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B17:U17").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B18").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B18"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B18:U18").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B18").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B18"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B18:U18").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B19").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B19"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B19:U19").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B19").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B19"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B19:U19").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B20").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B20"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B20:U20").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B20").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B20"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B20:U20").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
Application.ScreenUpdating = True
Worksheets("PalDying").Range("B3:L3,A6:U26").ClearContents
Range("B3").Activate
End Sub
Code: Select all
Sub test()
Dim wb As Variant
Dim source As Range
If Worksheets("PalDying").Range("B6").Value = "" Then End
i = Worksheets("Dyreport").Range("A6:A23").Find(Range("D6"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("A4:R4").Copy
Worksheets("Dyreport").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B6").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B6"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B6:U6").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
i = Worksheets("Report").Range("A:A").Find(Range("B6"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B6:U6").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B7").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B7"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B7:U7").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B7").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B7"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B7:U7").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B8").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B8"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B8:U8").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B8").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B8"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B8:U8").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B9").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B9"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B9:U9").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B9").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B9"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B9:U9").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B10").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B10"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B10:U10").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B10").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B10"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B10:U10").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B11").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B11"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B11:U11").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B11").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B11"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B11:U11").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B12").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B12"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B12:U12").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B12").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B12"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B12:U12").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B13").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B13"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B13:U13").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B13").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B13"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B13:U13").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B14").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B14"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B14:U14").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B14").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B14"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B14:U14").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B15").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B15"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B15:U15").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B15").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B15"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B15:U15").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B16").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B16"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B16:U16").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B16").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B16"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B16:U16").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B17").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B17"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B17:U17").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B17").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B17"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B17:U17").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B18").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B18"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B18:U18").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B18").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B18"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B18:U18").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B19").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B19"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B19:U19").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B19").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B19"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B19:U19").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B20").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B20"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B20:U20").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteFormats, Transpose:=False
Application.CutCopyMode = True
If Worksheets("PalDying").Range("B20").Value = "" Then End
i = Worksheets("Report").Range("A:A").Find(Range("B20"), LookIn:=xlValues).Row
Worksheets("PalDying").Range("B20:U20").Copy
Worksheets("Report").Range("A" & i).PasteSpecial xlPasteValues, Transpose:=False
Application.CutCopyMode = True
Application.ScreenUpdating = True
Worksheets("PalDying").Range("B3:L3,A6:U26").ClearContents
Range("B3").Activate
End Sub
Code: Select all
Dim rall As Range, r As Range
With Worksheets("PalDying")
if .Range("b6").Value = "" Then End
Set rall = .Range("b6", .Range("b" & .Rows.Count).End(xlUp))
End With
For Each r In rall
i = Worksheets("Report").Range("A:A").Find(r, LookIn:=xlValues).Row
r.Resize(1, 20).Copy
Worksheets("Report").Range("a" & i).Resize(1, 20).PasteSpecial xlPasteFormats
Worksheets("Report").Range("a" & i).Resize(1, 20).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next r
Code: Select all
Sub senddata()
Dim rall As Range, r As Range
With Worksheets("form")
If .Range("b6").Value = "" Then End
Set rall = .Range("b6", .Range("b" & .Rows.Count).End(xlUp))
End With
Set wb = Workbooks.Open("C:\Users\IT\Desktop\บิลเงินสด\เส้นทางเอกสาร.xlsx", False, False)
For Each r In rall
i = Worksheets("เส้นทางเอกสาร").Range("a:a").Find(r, LookIn:=xlValues).Row
r.Resize(1, 14).Copy
Worksheets("เส้นทางเอกสาร").Range("a" & i).Resize.Offset(0, 0).PasteSpecial xlPasteFormats
Worksheets("เส้นทางเอกสาร").Range("a" & i).Resize.Offset(0, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next r
wb.Close True
Worksheets("form").Range("A6:N100").ClearContents
Range("B4").Activate
End Sub