简体   繁体   English

如何选择一系列单元格直到特定值

[英]How to select a range of cells until a specific value

I have a row with 100+ cells that have certain values.我有一排有 100 多个具有特定值的单元格。

I need to select all of those rows, until a specific value appears (lets say its the string "STOP").我需要选择所有这些行,直到出现特定值(可以说它的字符串“STOP”)。

Currently I have the following code that basically just lets me select everything until the last cell with a value in it.目前我有以下代码,它基本上只是让我选择所有内容,直到最后一个带有值的单元格。

Range(Selection, Selection.End(xlToRight)).Select

But, I need the selection to not go all the way to the end but right before the cell with "STOP" in it.但是,我需要选择不要一直走到最后,而是在带有“STOP”的单元格之前。

Trying looking across the row to find STOP and the column that defines the column_num argument of the second Cells..尝试跨行查找STOP和定义第二个 Cells 的column_num参数的

Range(Selection.Cells(1), Cells(Selection.Cells(1).Row, Application.Match("stop", Selection.Cells(1).EntireRow, 0)-1)).Select

I'm using Selection.Cells(1) because Selection could be more than one cell in more than one row and this will only work on a single row.我正在使用Selection.Cells(1)是因为 Selection 可能是不止一行中的多个单元格,而且这只适用于单行。

You might also want to start writing code without using Select and Selection.您可能还想在不使用 Select 和 Selection 的情况下开始编写代码。

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

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