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 SortAndDel()
' SortAndDel Macro
For i = 1 To 2
Sheets(i).Select
Application.Goto Reference:="OFFSET(R7C16,1,0,COUNTA(C3)-1,)"
Selection.FormulaR1C1 = "=IF(RC[-8]="""",-1,1)"
Range("B8").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
ActiveWorkbook.Worksheets("SV").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("SV").Sort.SortFields.Add Key:=Range("P8:P200"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("SV").Sort
.SetRange Range("B8:P200")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.Goto Reference:= _
"OFFSET(R8C1,IFERROR(MATCH(1,R8C16:R200C16,0)-1,1),10,COUNTA(C3)-IFERROR(MATCH(1,R8C16:R200C16,0),0),2)"
Selection.ClearContents
Application.Goto Reference:= _
"OFFSET(R8C1,IFERROR(MATCH(1,R8C16:R200C16,0)-1,0),1,COUNTA(C3)-IFERROR(MATCH(1,R8C16:R200C16,0),0),5)"
Selection.ClearContents
Application.Goto Reference:= _
"OFFSET(R7C16,1,0,COUNTA(C16)-1,)"
Selection.ClearContents
Next i
End Sub