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 ExpDataCol() ' ส่งออกข้อมูลการจัดซื้อทั้งหมด
Dim sFolderPath As String
Dim Path As String
Dim FName As String
On Error Resume Next
Application.ScreenUpdating = False
sFolderPath = "C:\" & "Pasadu"
If Dir(sFolderPath, vbDirectory) = "" Then
MkDir sFolderPath
End If
FName = "Exp"
On Error GoTo err
If MsgBox("คุณต้องการส่งออกข้อมูลการจัดซื้อทั้งหมด ใช่หรือไม่ ?", 36, "ยืนยันการส่งออกข้อมูลการจัดซื้อ") = 6 Then
Set myWB = ThisWorkbook
Set rngToSave = Range("B2:I3500")
rngToSave.Copy
Set tempWB = Application.Workbooks.Add(1)
With tempWB
.Sheets(1).Range("A1").PasteSpecial xlPasteValues
.SaveAs Filename:=sFolderPath & "\" & FName & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False, local:=True
.Close
MsgBox "ส่งออกไฟล์ไปไว้ที " & sFolderPath & "\" & FName, vbInformation
ActiveWorkbook.FollowHyperlink Address:=sFolderPath, NewWindow:=True
Application.ScreenUpdating = True
End With
err:
End If
Application.DisplayAlerts = True
Range("B2").Select
End Sub
Code: Select all
Sub ExpDataCol() ' ส่งออกข้อมูลการจัดซื้อทั้งหมด
Dim sFolderPath As String
Dim Path As String
Dim FName As String
On Error Resume Next
Application.ScreenUpdating = False
sFolderPath = "C:\" & "Pasadu"
If Dir(sFolderPath, vbDirectory) = "" Then
MkDir sFolderPath
End If
FName = "Exp"
On Error GoTo err
If MsgBox("คุณต้องการส่งออกข้อมูลการจัดซื้อทั้งหมด ใช่หรือไม่ ?", 36, "ยืนยันการส่งออกข้อมูลการจัดซื้อ") = 6 Then
Set myWB = ThisWorkbook
Set rngToSave = Range("B2:I3500")
rngToSave.Copy
Set tempWB = Application.Workbooks.Add(1)
Application.DisplayAlerts = false
With tempWB
.Sheets(1).Range("A1").PasteSpecial xlPasteValues
.SaveAs Filename:=sFolderPath & "\" & FName & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False, local:=True
.Close
MsgBox "ส่งออกไฟล์ไปไว้ที " & sFolderPath & "\" & FName, vbInformation
ActiveWorkbook.FollowHyperlink Address:=sFolderPath, NewWindow:=True
Application.ScreenUpdating = True
End With
err:
End If
Range("B2").Select
End Sub