เรามีข้อมูลที่ก็อปมาแล้ว เอามาใส่ตารางเอ็กเซล
บางช่องมันว่าง เราต้องการลบตารางช่องว่าง ให้เหลือแต่ข้อมูลเนื้อ ๆ ทำได้! ดังนี้
กด Alt+F11 เพื่อเปิด Visual Basic Editor(VBE)
ไปที่ Insert>Module
ก็อปปี้โค้ดนี้ แล้วเอาไปวางในโมดูล
Sub DeleteBlankRows1()
'Deletes the entire row within the selection if the ENTIRE row contains no data.
'We use Long in case they have over 32,767 rows selected.
Dim i As Long
'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
'We work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Subกด Alt+Q เพื่อกลับไปหน้าปกติ
เลือกส่วนของตารางที่จะทำการเอาช่องว่างเปล่าออก(ช่องที่ไม่มีข้อมูล/blank cell) อย่ากด Ctrl+a นะ มันจะรันนานมาก....
กด Alt+F8 แล้วคลิก Run
ทาด๊าาาาาาา!!! แหล่มเลย
Microsoft excel มันเจ๋งอย่างงี้!
No comments:
Post a Comment
คอมเมนท์ดิ ดิ ดิ ดิ!