[英]vba code to find a specific value and copy value in subsequent cell in the column and paste in a new sheet
I have a excel sheet with some data. 我有一些数据的Excel工作表。 In Column A, it has set of data, my objective is to copy the cell value below the cell which contains its value as "Line".
在A列中,它具有一组数据,我的目标是将单元格值复制到包含其值为“ Line”的单元格下面。
Columns("B:B").Select
Set cell = Selection.Find(What:="line", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If cell Is Nothing Then
'do it something
Else
'do it another thing
End If
But it is used to find only the cell value which contains as Line. 但是它仅用于查找包含为“行”的单元格值。
To reference the cell which is one row below, and zero columns to the right of, the cell referred to by your cell
variable you can use cell.Offset(1, 0)
. 要引用单元
cell
变量所引用的单元格下方一行且右侧右边零列的单元cell
,可以使用cell.Offset(1, 0)
。
(Obviously, this can only be done if cell
isn't Nothing
, so needs to be used only in the Else
leg of your code's If
statement.) (显然,这只能做,如果
cell
是不是Nothing
,所以必须在仅用于Else
你的代码的腿If
发言。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.