刪除整列有資料無底色
Dear all,此資料以A欄列為主,當A欄列下底色有顏色時,該列保留。
[color=Red]其餘有資料但無底色[/color],"[color=Red]整列刪除[/color]"。
還請大家幫忙
示意圖如下
原始資料
[attach]34732[/attach]
想要的狀況
[attach]34733[/attach]
[attach]34734[/attach] [b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118560&ptid=23616]1#[/url] [i]jsc0518[/i] [/b]
請測試看看,謝謝
Sub test()
Dim xR As Range, R%, Clr
Application.ScreenUpdating = False
R = 1
With Sheets(1)
If .AutoFilterMode Then .[a1].AutoFilter
For Each xR In .Range(.[a1], .Cells(.Rows.Count, 1).End(3))
Clr = xR.DisplayFormat.Interior.ColorIndex
If Clr <> -4142 Then
xR.Resize(, 1).Copy Sheets(2).Cells(R, 1)
R = R + 1
End If
Next
End With
Application.ScreenUpdating = True
End Sub [b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118562&ptid=23616]2#[/url] [i]samwang[/i] [/b]
Dear samwang,
您好,我想要在"原始資料"工作表下直接刪除無底色(有資料)的列(整列)
同一工作上執行,執行結果不需在複製到另一工作表上。
感謝您!:)
[attach]34737[/attach] [attach]34738[/attach] [i=s] 本帖最後由 samwang 於 2022-3-24 07:51 編輯 [/i]
[quote]回復 samwang
Dear samwang,
您好,我想要在"原始資料"工作表下直接刪除無底色(有資料)的列(整列)
同一 ...
[size=2][color=#999999]jsc0518 發表於 2022-3-23 20:38[/color] [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118567&ptid=23616][img]http://forum.twbts.com/images/common/back.gif[/img][/url][/size][/quote]
請再測試看看,謝謝
Sub test2()
Dim xR As Range, xU As Range, Clr
Application.ScreenUpdating = False
With Sheets(1)
If .AutoFilterMode Then .[a1].AutoFilter
For Each xR In .Range(.[a1], .Cells(.Rows.Count, 1).End(3))
Clr = xR.DisplayFormat.Interior.ColorIndex
If Not Clr <> -4142 Then
If xU Is Nothing Then Set xU = xR Else Set xU = Union(xR, xU)
End If
Next
End With
If Not xU Is Nothing Then xU.EntireRow.Delete
Application.ScreenUpdating = True
End Sub [b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118568&ptid=23616]4#[/url] [i]samwang[/i] [/b]
Dear samwang,
謝謝你可以用歐。
另外請教一下,若我的工作表為"工作表2"
是不是 Sheets(1) ---> 改成 [color=Red]Sheets(2)[/color] [quote]回復 samwang
Dear samwang,
謝謝你可以用歐。
另外請教一下,若我的工作表為"工作表2"
是不是 She ...
[size=2][color=#999999]jsc0518 發表於 2022-3-24 22:08[/color] [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118573&ptid=23616][img]http://forum.twbts.com/images/common/back.gif[/img][/url][/size][/quote]
如附件說明,謝謝 [b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118577&ptid=23616]6#[/url] [i]samwang[/i] [/b]
Dear samwang,
感謝您的熱心教導,感恩感恩!
頁:
[1]