[英]VBA code to copy cells in specific column and paste (value) it to cells in specific column on another Sheet based on conditions
[英]vba code to find a specific value and copy value in subsequent cell in the column and paste in a new sheet
我有一些数据的Excel工作表。 在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
但是它仅用于查找包含为“行”的单元格值。
要引用单元cell
变量所引用的单元格下方一行且右侧右边零列的单元cell
,可以使用cell.Offset(1, 0)
。
(显然,这只能做,如果cell
是不是Nothing
,所以必须在仅用于Else
你的代码的腿If
发言。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.