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 ListStudentNameToPDF() 'พิมพ์บัญชีรายชื่อนักเรียนทั้งหมด
Dim sFolderPath As String
Dim Path As String
Dim FName As String
On Error Resume Next
sFolderPath = Sheet2.Range("K1").Value & "SchoolLunch"
If Dir(sFolderPath, vbDirectory) = "" Then
MkDir sFolderPath
End If
sFolderPath = Sheet2.Range("K1").Value & "SchoolLunch" & "\" & "PDF"
If Dir(sFolderPath, vbDirectory) = "" Then
MkDir sFolderPath
End If
FName = ActiveSheet.Range("B10")
Application.DisplayAlerts = False
Application.ScreenUpdating = False
If MsgBox("คุณต้องการพิมพ์บัญชีรายชื่อนักเรียนทั้งหมด ใช่หรือไม่?", 36, "ยืนยันการสั่งพิมพ์") = 6 Then
For i = 2 To Application.Count(Sheet2.Range("F2:F" & Sheet2.Range("F" & Rows.Count).End(xlUp).Row)) + 1
Sheet2.Range("E2").Value = Sheet2.Range("F" & i).Value
Sheet3.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFolderPath & "\" & Sheet3.Range("B10").Value
Next i
ActiveWorkbook.FollowHyperlink Address:=sFolderPath, NewWindow:=True
Else
MsgBox "คุณได้ยกเลิกการสั่งพิมพ์", vbInformation, "Cencel Printing"
End If
Sheet2.Range("E2").Value = 4
Application.ScreenUpdating = True
End Sub
Code: Select all
'Other code
If MsgBox("คุณต้องการพิมพ์บัญชีรายชื่อนักเรียนทั้งหมด ใช่หรือไม่?", 36, "ยืนยันการสั่งพิมพ์") = 6 Then
For i = 2 To Application.Count(Sheet2.Range("F2:F" & Sheet2.Range("F" & Rows.Count).End(xlUp).Row)) + 1
Sheet2.Range("E2").Value = Sheet2.Range("F" & i).Value
If Sheet3.Range("D8").Value <> "" Then
Sheet3.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFolderPath & "\" & Sheet3.Range("B10").Value
End If
Next i
ActiveWorkbook.FollowHyperlink Address:=sFolderPath, NewWindow:=True
Else
'Other code