vba代码仅选择除标题之外的特定列中的可见单元格 [英] vba code to select only visible cells in specific column except heading

查看:482
本文介绍了vba代码仅选择除标题之外的特定列中的可见单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要代码来选择除标题之外的特定列中的可见单元格...请帮助我

I need the code to select only visible cells in specific column except heading... please help me

这是我尝试的

ActiveSheet.UsedRange.Offset(1, 0).SpecialCells(xlCellTypeVisible).Copy

但它将选择除标题之外的所有列。我只需要特定的列只需要列D

But It will select all the column except heading. I need it only to the specific column just take column D

推荐答案

这将选择所有可见单元格与D列中的数据,除标题和最后一个可见单元格,数据:

This will select all visible cells with data in column D, except header and last visible cell with data:

Option Explicit

Sub SelectVisibleInColD()
    Dim lRow As Long

    With ActiveSheet

        lRow = .Cells(.Rows.Count, 4).End(xlUp).Row

        If lRow < 3 Then Exit Sub

        .Cells(1, 4).Offset(1, 0).Resize(lRow - 2).SpecialCells(xlCellTypeVisible).Select

    End With
End Sub

这篇关于vba代码仅选择除标题之外的特定列中的可见单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆