Board logo

標題: 如何刪除空白欄,而不是整列刪除? [打印本頁]

作者: jumky    時間: 2018-9-25 20:06     標題: 如何刪除空白欄,而不是整列刪除?

請問各位大大:
要如何刪除空白欄,讓特定的兩欄之下方資料往上移?(詳如附件[attach]29445[/attach])
作者: 准提部林    時間: 2018-9-28 10:43

Sub TEST()
Dim xArea As Range, xU As Range, xR As Range
Set xArea = Intersect(ActiveSheet.UsedRange, [B:F])
Set xU = xArea(xArea.Rows.Count + 1, 1)
For Each xR In xArea
    If xR.Column Mod 2 Or xR & xR(1, 2) <> "" Then GoTo 101
    Set xU = Union(xU, xR, xR(1, 2))
101: Next
If xU.Count > 1 Then xU.Delete Shift:=xlUp
End Sub
作者: jumky    時間: 2018-10-2 19:23

謝謝准提部林大大~




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)