snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
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
You do not have the required permissions to view the files attached to this post.
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