將空白欄,刪除
Sub 刪除空白欄()
'
Cells(1, ActiveSheet.Columns.Count).Select '選到最左邊
Selection.End(xlToLeft).Select '從最左邊選回最右邊文字
AAA = ActiveCell.Column 'AAA = 最左邊最後的值
For i = 1 To AAA Step 1
If Cells(1, AAA) = "" Then
Cells(1, AAA).Delete
AAA = AAA - 1
Else
AAA = AAA - 1
If AAA = 0 Then '如果刪到最後第A欄就結束程式
GoTo 1
End If
End If
Next
1
End Sub
刪除空白欄方法二 (進階)
Public Sub 空白欄刪除2()
Cells(1, ActiveSheet.Columns.Count).Select '選到最左邊
Selection.End(xlToLeft).Select '從最左邊選回最右邊文字
AAA = ActiveCell.Column 'AAA = 最左邊最後的值
For i = AAA To 1 Step -1
If Cells(1, i) = "" Then
Columns(i).Delete
End If
Next
End Sub
將空白列"刪除
Sub 刪除空白列位()
'
Cells(ActiveSheet.Rows.Count, 1).Select '選到最下面
Selection.End(xlUp).Select '從最下面往上選回文字
AAA = ActiveCell.Row 'AAA = 最下面最後一行的值
For i = 1 To AAA Step 1
If Cells(AAA, 1) = "" Then
Cells(AAA, 1).Delete
AAA = AAA - 1
Else
AAA = AAA - 1
If AAA = 0 Then '如果刪到最後第A欄就結束程式
GoTo 1
End If
End If
Next
1
End Sub
空白列刪除方法二 (進階)
Public Sub 空白列刪除()
Cells(ActiveSheet.Rows.Count, 1).Select '選到最下面
Selection.End(xlUp).Select '從最下面往上選回文字
AAA = ActiveCell.Row 'AAA = 最下面最後一行的值
For i = AAA To 1 Step -1
If Cells(i, 1) = "" Then '碰到列是空白的刪除
Rows(i).Delete
End If
Next
End Sub
留言列表