簡體   English   中英

在 excel vba 中選擇了 SpecialCells(xlCellTypeVisible) 額外行

[英]SpecialCells(xlCellTypeVisible) extra row is selected in excel vba

圖像1 圖2

大家好,

目前正在處理 SpecialCells(xlCellTypeVisible) ,在過濾數據后,單元格會以綠色突出顯示,如圖 1 所示,但是當使用公式時,行號也會被選中。

我需要獲得可見單元格的結果將突出顯示,沒有添加額外的行,如圖 2 所示。

下面是使用的公式。

OB2.ActiveSheet.UsedRange.Offset(1, 0).SpecialCells(xlCellTypeVisible).Rows.Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorAccent6
            .TintAndShade = 0.399975585192419
            .PatternTintAndShade = 0
        End With

我們嘗試使用.Offset(1,0)刪除 header 。 但是,這會在底部添加一行。 考慮:

Sub RemoveHeaderRow()
    Dim tablee As Range
    Dim tableeBody As Range

    Set tablee = Range("A1").CurrentRegion
    Set tableeBody = tablee.Offset(1, 0).Resize(tablee.Rows.Count - 1, tablee.Columns.Count)

    tableeBody.Select
End Sub

在此處輸入圖像描述

這是使用SpecialCells的范圍。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM