Submit Search
Upload
Macro VBA Excel2010 by A'Rong
•
1 like
•
791 views
smittichai chaiyawong
Follow
Macro VBA Excel2010
Read less
Read more
Software
Report
Share
Report
Share
1 of 84
Download now
Download to read offline
Recommended
Advanced excel 2010
Advanced excel 2010
smittichai chaiyawong
Operations Research and Optimization in Python using PuLP
Operations Research and Optimization in Python using PuLP
Guy K. Kloss
Applying Linear Optimization Using GLPK
Applying Linear Optimization Using GLPK
Jeremy Chen
Tutorial: Python, PuLP and GLPK
Tutorial: Python, PuLP and GLPK
sucha
MS-EXCEL Assignment Help
MS-EXCEL Assignment Help
Rahul Kataria
Advances in ms excel
Advances in ms excel
Mohit Kumar
Advanced Excel ppt
Advanced Excel ppt
Sudipta Mazumder
Excel 2010 Unit A PPT
Excel 2010 Unit A PPT
okmomwalking
Recommended
Advanced excel 2010
Advanced excel 2010
smittichai chaiyawong
Operations Research and Optimization in Python using PuLP
Operations Research and Optimization in Python using PuLP
Guy K. Kloss
Applying Linear Optimization Using GLPK
Applying Linear Optimization Using GLPK
Jeremy Chen
Tutorial: Python, PuLP and GLPK
Tutorial: Python, PuLP and GLPK
sucha
MS-EXCEL Assignment Help
MS-EXCEL Assignment Help
Rahul Kataria
Advances in ms excel
Advances in ms excel
Mohit Kumar
Advanced Excel ppt
Advanced Excel ppt
Sudipta Mazumder
Excel 2010 Unit A PPT
Excel 2010 Unit A PPT
okmomwalking
Ms excel
Ms excel
Kuriachan Manuel
Advanced Microsoft Excel
Advanced Microsoft Excel
Eric Metelka
2016 ms excel_bm
2016 ms excel_bm
Rajesh Math
Microsoft Excel Project 1 Presentation
Microsoft Excel Project 1 Presentation
jmartinvvc
Advanced Excel &Basic Excel Training
Advanced Excel &Basic Excel Training
aarkex
MS Excel Training 01
MS Excel Training 01
Michael Sheyahshe
Facility location and techniques
Facility location and techniques
Piyush Sharma
MS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATION
Mridul Bansal
Infographic presentation
Infographic presentation
smittichai chaiyawong
Adobe premiere pro cc 2018
Adobe premiere pro cc 2018
smittichai chaiyawong
Infographic presentation
Infographic presentation
smittichai chaiyawong
Cinemagraph by photoshop
Cinemagraph by photoshop
smittichai chaiyawong
Motion graphic by ppt
Motion graphic by ppt
smittichai chaiyawong
Static excel
Static excel
smittichai chaiyawong
การใช้งาน Power point 2013
การใช้งาน Power point 2013
smittichai chaiyawong
Excel 2013
Excel 2013
smittichai chaiyawong
02 word 2013
02 word 2013
smittichai chaiyawong
Ms excel 2016
Ms excel 2016
smittichai chaiyawong
Ms outlook 2016
Ms outlook 2016
smittichai chaiyawong
Windows 10
Windows 10
smittichai chaiyawong
แนะนำ ProjectLibre
แนะนำ ProjectLibre
smittichai chaiyawong
Excel 2010 basic finish
Excel 2010 basic finish
smittichai chaiyawong
More Related Content
Viewers also liked
Ms excel
Ms excel
Kuriachan Manuel
Advanced Microsoft Excel
Advanced Microsoft Excel
Eric Metelka
2016 ms excel_bm
2016 ms excel_bm
Rajesh Math
Microsoft Excel Project 1 Presentation
Microsoft Excel Project 1 Presentation
jmartinvvc
Advanced Excel &Basic Excel Training
Advanced Excel &Basic Excel Training
aarkex
MS Excel Training 01
MS Excel Training 01
Michael Sheyahshe
Facility location and techniques
Facility location and techniques
Piyush Sharma
MS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATION
Mridul Bansal
Viewers also liked
(8)
Ms excel
Ms excel
Advanced Microsoft Excel
Advanced Microsoft Excel
2016 ms excel_bm
2016 ms excel_bm
Microsoft Excel Project 1 Presentation
Microsoft Excel Project 1 Presentation
Advanced Excel &Basic Excel Training
Advanced Excel &Basic Excel Training
MS Excel Training 01
MS Excel Training 01
Facility location and techniques
Facility location and techniques
MS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATION
More from smittichai chaiyawong
Infographic presentation
Infographic presentation
smittichai chaiyawong
Adobe premiere pro cc 2018
Adobe premiere pro cc 2018
smittichai chaiyawong
Infographic presentation
Infographic presentation
smittichai chaiyawong
Cinemagraph by photoshop
Cinemagraph by photoshop
smittichai chaiyawong
Motion graphic by ppt
Motion graphic by ppt
smittichai chaiyawong
Static excel
Static excel
smittichai chaiyawong
การใช้งาน Power point 2013
การใช้งาน Power point 2013
smittichai chaiyawong
Excel 2013
Excel 2013
smittichai chaiyawong
02 word 2013
02 word 2013
smittichai chaiyawong
Ms excel 2016
Ms excel 2016
smittichai chaiyawong
Ms outlook 2016
Ms outlook 2016
smittichai chaiyawong
Windows 10
Windows 10
smittichai chaiyawong
แนะนำ ProjectLibre
แนะนำ ProjectLibre
smittichai chaiyawong
Excel 2010 basic finish
Excel 2010 basic finish
smittichai chaiyawong
Advance word2013
Advance word2013
smittichai chaiyawong
เอกสาร Infographic
เอกสาร Infographic
smittichai chaiyawong
slide intro Infographic
slide intro Infographic
smittichai chaiyawong
Logical Excel
Logical Excel
smittichai chaiyawong
PowerPoint2010 Concept
PowerPoint2010 Concept
smittichai chaiyawong
Facebook marketingonline
Facebook marketingonline
smittichai chaiyawong
More from smittichai chaiyawong
(20)
Infographic presentation
Infographic presentation
Adobe premiere pro cc 2018
Adobe premiere pro cc 2018
Infographic presentation
Infographic presentation
Cinemagraph by photoshop
Cinemagraph by photoshop
Motion graphic by ppt
Motion graphic by ppt
Static excel
Static excel
การใช้งาน Power point 2013
การใช้งาน Power point 2013
Excel 2013
Excel 2013
02 word 2013
02 word 2013
Ms excel 2016
Ms excel 2016
Ms outlook 2016
Ms outlook 2016
Windows 10
Windows 10
แนะนำ ProjectLibre
แนะนำ ProjectLibre
Excel 2010 basic finish
Excel 2010 basic finish
Advance word2013
Advance word2013
เอกสาร Infographic
เอกสาร Infographic
slide intro Infographic
slide intro Infographic
Logical Excel
Logical Excel
PowerPoint2010 Concept
PowerPoint2010 Concept
Facebook marketingonline
Facebook marketingonline
Macro VBA Excel2010 by A'Rong
1.
smitrong@hotmail.com 1
2.
Record Macro1: run1to10 smitrong@hotmail.com 2
3.
Run Macro1: run1to10 smitrong@hotmail.com 3
4.
Record Macro2: auto1to10 smitrong@hotmail.com 4
5.
Run Macro2: auto1to10 smitrong@hotmail.com 5
6.
Record Macro3: CopyData smitrong@hotmail.com 6
7.
1. คลิก Sheet
ชลบุรี 2. ลากคลุม D3:D16 3. คัดลอก (Copy) 4. คลิก Sheet รวมยอดขาย 5. คลิก C3 6. วาง (Paste) แบบ Value 7. คลิก Sheet กทม 8. ลากคลุม D3:D16 9. คัดลอก (Copy) 10. คลิก Sheet รวมยอดขาย 11. คลิก D3 12. วาง (Paste) แบบ Value smitrong@hotmail.com 7
8.
13. คลิก Sheet
เชียงใหม่ 14. ลากคลุม D3:D16 15. คัดลอก (Copy) 16. คลิก Sheet รวมยอดขาย 17. คลิก E3 18. วาง (Paste)แบบ Value 19. คลิก F2 พิมพ์คาว่า รวม 20. คลิก F3 ใช้ Sum 21. คัดลอกจนถึง F16 smitrong@hotmail.com 8
9.
Run Macro3: CopyData smitrong@hotmail.com 9
10.
Record Macro4: AddData smitrong@hotmail.com 10
11.
1. คลิก Sheet
ชลบุรี 2. คลิก B3 4. กด ctrl + shift + ลูกศรลง 5. กด ctrl + shift + ลูกศรขวา 6. คัดลอก (Copy) 8. คลิก Sheet เรียงยอดขาย 10. กด ctrl + Home 11. กด ctrl + ลูกศรลง 12. กด ลูกศรลง 13. วาง (Paste) smitrong@hotmail.com 11
12.
1. คลิก Sheet
กทม 2. คลิก B3 4. กด ctrl + shift + ลูกศรลง 5. กด ctrl + shift + ลูกศรขวา 6. คัดลอก (Copy) 8. คลิก Sheet เรียงยอดขาย 10. กด ctrl + Home 11. กด ctrl + ลูกศรลง 12. กด ลูกศรลง 13. วาง (Paste) smitrong@hotmail.com 12
13.
1. คลิก Sheet
เชียงใหม่ 2. คลิก B3 4. กด ctrl + shift + ลูกศรลง 5. กด ctrl + shift + ลูกศรขวา 6. คัดลอก (Copy) 8. คลิก Sheet เรียงยอดขาย 10. กด ctrl + Home 11. กด ctrl + ลูกศรลง 12. กด ลูกศรลง 13. วาง (Paste) smitrong@hotmail.com 13
14.
15. คลิก Sheet
เรียงยอดขาย 16. คลิก C2 18. กด ctrl + ลูกศรลง 19. กด ลูกศรลง 20. ใช้ Sum smitrong@hotmail.com 14
15.
Run Macro4: AddData smitrong@hotmail.com 15
16.
Record Macro5: InputData smitrong@hotmail.com 16
17.
1. คลิก Sheet
Input 2. ลากคลุม B12:G12 (ช่วงข้อมูลที่ต้องการ) 3. คัดลอก (Copy) smitrong@hotmail.com 17
18.
4. คลิก Sheet
Data 5. คลิก A1 7. กด ctrl + ลูกศรลง 8. กด ลูกศรลง 9. วาง (Paste) แบบ Value smitrong@hotmail.com 18
19.
Run Macro5: InputData smitrong@hotmail.com 19
20.
Record Macro6: ClearData smitrong@hotmail.com 20
21.
1. คลิก Sheet
Input 2. คลิก B2 กด ctrl คลิก B3,B6,B7 3. กด Delete 4. คลิก B2 smitrong@hotmail.com 21
22.
Run Macro6: ClearData smitrong@hotmail.com 22
23.
smitrong@hotmail.com 23
24.
Object :การอ้างอิงวัตถุ • Cell –
Range(“ชื่อเซล") :ระบุตาแหน่ง – ActiveCell :เซลปัจจุบัน, ที่เริ่มเลือก – Selection :เซลทั้งหมดที่คลุม • Sheet – Sheets(เลขชีท) :ระบุตาแหน่งที่ – Sheets(“ชื่อชีท") :ระบุชื่อ – ActiveSheet :ซีทปัจจุบัน smitrong@hotmail.com 24
25.
Statement :การเขียนรูปประโยคคาสั่ง Object Property Parameter Method
ขยาย Method ขยาย Object • Property • Method smitrong@hotmail.com 25
26.
Property • Cell –Value :
กาหนดค่าใน Cell –Font : กาหนดลักษณะ Font • Sheet –Name : กาหนดชื่อ Sheet smitrong@hotmail.com 26
27.
VBA1 :TypeDate smitrong@hotmail.com 27
28.
1. พิมพ์ Sub
เว้นวรรค 2. ตั้งชื่อคาสั่ง เปิด-ปิด วงเล็บ 3. กด Enter 4. End Sub จะขึ้นเองไม่ต้องพิมพ์ • Range("A1").Value = "จันทร์“ smitrong@hotmail.com 28
29.
Run VBA1 :TypeDate smitrong@hotmail.com 29
30.
VBA2 :FormatCell 1. ตั้ง
Sub ชื่อ FormatCell 2. เขียน Statement –ActiveCell.Font.Bold = True ->ให้ข้อความเป็นตัวหนา –ActiveCell.Font.Size = 20 ->ให้ข้อความมีขนาด20 –ActiveCell.Font.ColorIndex = 3 ->ให้ข้อความเป็นสีแดง *ต้องการสีอื่นทดลองเปลี่ยนตัวเลขเอง smitrong@hotmail.com 30
31.
Run VBA2 :FormatCell smitrong@hotmail.com 31
32.
VBA3 :FormatAll 1. ตั้ง
Sub ชื่อ FormatCell 2. เขียน Statement –Selection.Font.Bold = False ->ให้ข้อความไม่เป็นตัวหนา –Selection.Font.Size = 11 ->ให้ข้อความมีขนาด11 –Selection.Font.ColorIndex= 1 ->ให้ข้อความเป็นสีดา *ต้องการสีอื่นทดลองเปลี่ยนตัวเลขเอง smitrong@hotmail.com 32
33.
Run VBA3 :FormatAll smitrong@hotmail.com 33
34.
VBA4 :SheetName 1. ตั้ง
Sub ชื่อ FormatCell 2. เขียน Statement –ActiveSheet.Name = ActiveCell.Value ->ให้ชื่อชีทเท่ากับชื่อเซลที่เลือก *ถ้าเซลที่เลือกเป็นเซลว่างจะเกิด Error smitrong@hotmail.com 34
35.
Run VBA4 :SheetName smitrong@hotmail.com 35
36.
Method • Cell –Clear :
ลบค่าใน Cell –Offset, Select : เลื่อน Cell –Copy, Paste: คัดลอก วางค่าใน Cell • Sheet –Add: เพิ่ม Sheet smitrong@hotmail.com 36
37.
VBA5 :DeleteData 1. ตั้ง
Sub ชื่อ DeleteData 2. เขียน Statement –Selection.Clear ->ลบข้อมูลบริเวณที่เลือก smitrong@hotmail.com 37
38.
Run VBA5 :DeleteData smitrong@hotmail.com 38
39.
VBA6 :TypeDirect 1. ตั้ง
Sub ชื่อ TypeDirect 2. เขียน Statement –ActiveCell.Value = "North“ ->ที่เซลปัจจบันพิมพ์ “North” –ActiveCell.Offset(1, 1).Value = "East" ->ที่เซลปัจจบันเลื่อนไป 1 row 1 column พิมพ์ “East” –ActiveCell.Offset(1, 0).Select ->เลือกลงมา 1 แถวจากเซลปัจจุบัน smitrong@hotmail.com 39
40.
Run VBA6 :TypeDirect smitrong@hotmail.com 40
41.
VBA7 :CopyPaste 1. ตั้ง
Sub ชื่อ CopyPaste 2. เขียน Statement –ActiveCell.Copy ->คัดกลอกจากเซลปัจจุบัน –ActiveCell.Offset(0, 1).Select ->เลือกไปขวา 1 ช่อง –ActiveCell.PasteSpecial xlPasteValues ->วางข้อมูลลง –ActiveCell.Offset(0, 1).Select ->เลือกไปขวา 1 ช่อง –ActiveSheet.Paste ->วางข้อมูลลง smitrong@hotmail.com 41
42.
Run VBA7 :CopyPaste smitrong@hotmail.com 42
43.
VBA8 :AddSheet 1. ตั้ง
Sub 2. เขียน Statement –Sheets.Add ->เพิ่มชีท –ActiveSheet.Name = "Qrt4" ->ใส่ชื่อเป็น “Ort4” *คัดลอกวาง 4 ชุดแล้วเปลี่ยนเป็น Qtr3 Qtr2 Qtr1 ตามลาดับ smitrong@hotmail.com 43
44.
Run VBA8 :AddSheet smitrong@hotmail.com 44
45.
Function • MsgBox : –i
= MsgBox(“Prompt", Buttons, "Title") • i : ตัวแปรรับค่าจากตอบ Button ใน MsgBox • Prompt : ข้อความแสดงใน MsgBox • Button : ปุ่มให้คลิกตอบ • Title : ข้อความหัวข้อ • InputBox : –i = InputBox (“Prompt", "Title",Default) • i : ตัวแปรรับค่าจาก InputBox • Prompt : ข้อความแสดงใน InputBox • Title : ข้อความหัวข้อ • Default : ค่าเริ่มต้น smitrong@hotmail.com 45
46.
VBA9 :MsgBox 1. เมื่อสั่ง
Run จะได้ 2. เมื่อสั่ง Run จะลบข้อมูลที่คลุม แล้วจะได้ smitrong@hotmail.com 46
47.
VBA10 :InputBoxCal 1. ตั้ง
Sub 2. เขียน Statement –รับค่าส่วนสูงเก็บไว้ที่ I –ที่เซลแสดงข้อความ “ค่าน้าหนักที่เหมาะสม" –ลง 1 ช่องแสดงข้อความ “เพศชาย" –ลง 1 ช่อง ขวา 1 ช่อง แสดง I-105 –ลง 2 ช่องแสดงข้อความ “เพศหญิง" –ลง 2 ช่อง ขวา 1 ช่อง แสดง I-115 smitrong@hotmail.com 47
48.
Run VBA10 :InputBoxCal smitrong@hotmail.com 48
49.
Variable • Dim ชื่อตัวแปร
As ชนิด – Integer –Long –String –Date –Variant • Dim I As Integer –ตัวแปร I เก็บค่าได้ -32768 ถึง 32767 smitrong@hotmail.com 49
50.
VBA11 :InputBoxTax 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปรต่างๆ –>InputBox รับค่าต่างๆ –>คานวณ –>แสดงค่า smitrong@hotmail.com 50
51.
Run VBA11 :InputBoxTax smitrong@hotmail.com 51
52.
Control Structure • Condition –If…Then…Else –Select…Case •
Loop –For…To…Next –Do While…Loop –Do Unit…Loop –Do…Loop While –Do…Loop Unit smitrong@hotmail.com 52
53.
VBA12 :IfBlank 1. ตั้ง
Sub 2. เขียน Statement – ถ้า เซลปัจจุบันเท่ากับว่าง ให้ –> ให้เซลปัจจุบันแสดง “ไม่มีค่า” –ถ้าไม่ –> ให้เซลปัจจุบัน เป็นตัวหนา –> ให้เซลปัจจุบันเป็นสีแดง –จบเงื่อนไข smitrong@hotmail.com 53
54.
Run VBA12 :IfBlank smitrong@hotmail.com 54
55.
VBA13 :IfSocialCal 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปรต่างๆ –>InputBox รับค่าต่างๆ – ถ้า เงินเดือน <= 1650 ให้ –> Cal =83 – ถ้า เงินเดือน >= 15000 ให้ –> Cal =750 –ถ้าไม่ –> คานวณ Cal =เงินเดือน คูณ 5% –จบเงื่อนไข –>>แสดงค่า ปกติ 5% ของค่าจ้าง *ขั้นต่าเดือนละ 1,650 บาท เงินสมทบ 83 บาท **ขั้นสูงเดือนละ 15,000 บาท เงินสมทบ 750 บาทsmitrong@hotmail.com 55
56.
Run VBA13 :IfSocialCal smitrong@hotmail.com 56
57.
VBA14 :IfDelect 1. ตั้ง
Sub 2. เขียน Statement –>MsgBox รับค่า (Ok=1, Cancel=2) –>ถ้า i=1 ให้ –>ลบบริเวณที่เลือก –>จบ smitrong@hotmail.com 57
58.
Run VBA14 :IfDelect smitrong@hotmail.com 58
59.
VBA15 :CaseGrade 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปร –>InputBox รับค่า –ตรวจสอบว่าอยู่ในช่วง Case ใน –แสดงMsgBox ของ Case นั้น smitrong@hotmail.com 59
60.
Run VBA15 :CaseGrade smitrong@hotmail.com 60
61.
VBA16 :CaseCom 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปร –>ตัวแปร Sale เท่ากันค่าในเซลปัจจุบัน –ตรวจสอบว่าอยู่ในช่วง Case ใน –ถัดไป 1 ช่อง คานวณ Cal ค่าใน Case นั้น –เลือกลง 1 ช่อง smitrong@hotmail.com 61
62.
Run VBA16 :CaseCom smitrong@hotmail.com 62
63.
VBA17 :For1to10 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปร –>ตัวแปร I เริ่มที่ 1 ถึง 10 –เซลปัจจุบันเท่ากับ i –เลือกลง 1 ช่อง –>ตัวแปร I เพิ่มขึ้น 1 smitrong@hotmail.com 63
64.
Run VBA17 :For1to10 smitrong@hotmail.com 64
65.
VBA18 :For1toNum 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปร –>InputBox รับค่า Num –>ตัวแปร I เริ่มที่ 1 ถึง Num –เซลปัจจุบันเท่ากับ i –เลือกลง 1 ช่อง –>ตัวแปร I เพิ่มขึ้น 1 smitrong@hotmail.com 65
66.
VBA18 :For1toNum 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปร Num เป็น String –> ถ้าตอบ Cancel จะได้ Num เป็นค่าว่าง จะเกิด Error smitrong@hotmail.com 66
67.
Run VBA18 :For1toNum smitrong@hotmail.com 67
68.
VBA19 :ForAddSheet 1. ตั้ง
Sub 2. เขียน Statement –> ตั้งตัวแปร –>InputBox รับค่า Num –>ตัวแปร I เริ่มที่ 1 ถึง Num –เพิ่มชีท หลังชีทลาดับสุดท้าย (ที่นับได้) –ชื่อชีทเท่ากับ i –>ตัวแปร I เพิ่มขึ้น 1 smitrong@hotmail.com 68
69.
Run VBA19 :ForAddSheet smitrong@hotmail.com 69
70.
VBA20 :DoWhGrad –> ตั้งตัวแปร –>ตรวจสอบค่าในช่องเซล
ถ้าไม่เท่ากับว่าง (หมายถึงมีค่า) ก็ทา statement ด้านใน ถ้าเท่ากับว่าง ก็ไม่ต้องทา ข้ามไปที่ Loop –>เลื่อนลง 1 ช่อง –>วนกับไปทาใหม่ ที่ Do while smitrong@hotmail.com 70
71.
Run VBA20 :DoWhGrad smitrong@hotmail.com 71
72.
VBA21 :DoUnDigi –> ตั้งตัวแปร –>ตรวจสอบถ้าค่า
I > total ข้ามไปที่ Loop ถ้า i<=total ก็ทา statement ด้านใน –>เลื่อนลง 1 ช่อง –>วนกับไปทาใหม่ ที่ Do Untilsmitrong@hotmail.com 72
73.
Run VBA21 :DoUnDigi smitrong@hotmail.com 73
74.
VBA22 :LoopWhAmount –> ทางานทันที –>sale
เท่ากับค่าด้านบน –>sale เป็นตัวเลขหรือไม่ –>ถ้าใช่เซลปัจจุบัน เท่ากับ Sale บวกเซลด้านหน้า –>ถ้าไม่ เซลปัจจุบัน เท่ากับเซลด้านหน้า –เลื่อนเซลลง 1 ช่อง –ถ้าเซลปัจจุบันเท่ากับว่าง และเซลด้านหน้าไม่ว่าง (หมายถึงมีค่า)ให้วนขึ้นไปทาDo ใหม่ smitrong@hotmail.com 74
75.
Run VBA22 :LoopWhAmount smitrong@hotmail.com 75
76.
VBA23 :LoopUnVax –รับค่า vax –>
ทางานทันที –เซลถัดไป เท่ากับเซลปัจจุบัน* vax –เลื่อนเซลลง 1 ช่อง –ถ้าเซลปัจจุบันว่าง ก็จบการทางาน ไม่ต้องวนขึ้นไปทา Do ใหม่ smitrong@hotmail.com 76
77.
Run VBA23 :LoopUnVax smitrong@hotmail.com 77
78.
Great Functions In
VBA สร้าง Function ชื่อ(ตัวแปร As ชนิดตัวแปร) As ชนิดฟังชั่น statement Function เรียกใช้ = ชื่อ(ตัวแปร) smitrong@hotmail.com 78
79.
Fx1 :Age(birthday) smitrong@hotmail.com 79
80.
Fx2 :SetPrice(unit,cost,profit) smitrong@hotmail.com 80
81.
Fx3 :PaySocial(Salary) smitrong@hotmail.com 81
82.
smitrong@hotmail.com 82
83.
–รับค่าจานวนบรรทัด(line) –สร้าง I ไว้เช็คกับค่า
line –Do ใหญ่ไว้เช็ค I กับline • Do ใช้คานวณ • บวก I เพื่อใช้นับค่า • นา Salary มา* 7% • แสดงค่าในช่องถัดไป • เลื่อนลง 1 ช่อง • ถ้าเซลว่าง จบ Loop ไม่ต้องวนทา • (หมายความว่า ถ้าเซลมีค่า ก็วน Loop ไปคานวน) • Do เซ็คบรรทัดว่าง • บวก I เพื่อใช้นับค่า • เลื่อนลง 1 ช่อง • ถ้า ค่าเซลว่าง และ I ยังไม่มากกว่า line ก็วน Loop ไปทางาน • *ถ้าเซลมีค่าก็จะหลุดออกมา เซ็ค Loop ใหญ่ –ถ้า I ยังไม่มากกว่า line ก็วน Loop ไปทางานsmitrong@hotmail.com 83
84.
smitrong@hotmail.com 84
Download now