繁体   English   中英

vba代码以查找特定值并在该列的后续单元格中复制值并粘贴到新工作表中

[英]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.

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