简体   繁体   English

在 excel vba 中选择了 SpecialCells(xlCellTypeVisible) 额外行

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

图像1 图2

Hello All,大家好,

Currently working on SpecialCells(xlCellTypeVisible) where after filtering data, the cells would get highlighted with green color as shown in image 1, but when the formula is used Row no is also getting selected.目前正在处理 SpecialCells(xlCellTypeVisible) ,在过滤数据后,单元格会以绿色突出显示,如图 1 所示,但是当使用公式时,行号也会被选中。

The result which I need to get visible cells would highlighted with no extra row added as shown in image 2.我需要获得可见单元格的结果将突出显示,没有添加额外的行,如图 2 所示。

Below is formula used.下面是使用的公式。

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

We try to remove the header by using .Offset(1,0) .我们尝试使用.Offset(1,0)删除 header 。 This however adds a row to the bottom.但是,这会在底部添加一行。 Consider:考虑:

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

在此处输入图像描述

This is the range to use SpecialCells on.这是使用SpecialCells的范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM