在A列中选择包含内容的单元格? [英] Selecting the cells, with contents, in column A?

查看:93
本文介绍了在A列中选择包含内容的单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在A列中选择包含内容的单元格?

How do I select the cells, with contents, in column A?

例如

我可能有一个姓名列表

John 
Jack 
James

和其他更长的时间列表

John 
Jack
James
Jimmy

这些将始终位于单元格A1-AX中,X是最后一行.

These will always be in cell A1-AX, X being the final row.

对于第一个示例,我将使用代码

For the first example, I would use the code,

Range("A1:A3").Select

第二次,

Range("A1:A4").Select

我想使用自动执行此操作的代码,而不管列表中有多少.

I would like to use code that automates this regardless of how many in the list.

推荐答案

在代码的第四行上编辑工作表名称(在此处保留引号),然后运行代码.

Edit the sheet name on the 4th line of code (leave quotes there) and then run the code.

Option Explicit

Sub LRow()

    Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")  '<=== Edit Sheet Name
    Dim LRow As Long

    LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

    ws.Range("A1:A" & LRow).Select

End Sub

这篇关于在A列中选择包含内容的单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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