vba 如何跳转到单元格包含特定文本的第一行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18846008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:37:54  来源:igfitidea点击:

How to jump to first row where a cell contains a certain text

excel-vbavbaexcel

提问by Morten Laustsen

I have a spreadsheet where I've found some code that jumps to the first empty row:

我有一个电子表格,我在其中找到了一些跳转到第一个空行的代码:

 lastRowA = Range("A" & Rows.Count).End(xlUp).Row + 1
 ActiveWorkbook.Worksheets("RO input sheet").Range("A" & lastRowA).Select

My problem is that the conditions surrounding the spreadsheet have changed so now I need to tweak the code so it jumps to the first row where cell A contains a specific text, for instance "Test123".

我的问题是电子表格周围的条件已经改变,所以现在我需要调整代码,使其跳转到单元格 A 包含特定文本的第一行,例如“Test123”。

How can I do this in VBA?

我怎样才能在 VBA 中做到这一点?

回答by mattboy

Replace the entire code with simply:

用简单的替换整个代码:

ActiveWorkbook.Worksheets("RO input sheet").Columns(1).Find("Test123").Select