简体   繁体   English

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

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

相关问题 VBA代码可根据条件复制特定列中的单元格并将其粘贴(值)到另一张工作表中特定列中的单元格 - VBA code to copy cells in specific column and paste (value) it to cells in specific column on another Sheet based on conditions 复制并粘贴 excel 表,要在代码中引用的表单元格数据的值 - Copy and Paste a excel sheet , Value of Sheet Cell Data to be referenced in code 在与另一张工作表中的单元格值相等的列中搜索一个值,然后将粘贴复制到新位置 - Search for a value in a column which is equal to cell value in another sheet, then copy paste to new location VBA 根据日期将工作表 1 中的单元格值复制/粘贴到工作表 2 的宏 - VBA Macro to copy/paste cell value from sheet 1 to 2 based on date 代码不会将特定的单元格复制并粘贴到新工作表VBA中 - Code Won't Copy and Paste Specific Cells Into New Sheet VBA VBA 用于过滤的宏,从列中复制指定值并创建然后粘贴到具有该列名称的新工作表中 - VBA Macro to filter, copy the specified value from a column and create then paste in a new sheet with that column name VBA代码可将值从一个单元格复制到特定列 - VBA code to copy value from one cell to specific column Excel VBA从列复制值并将值粘贴到单元格中 - excel vba copy value from a column and paste value in a cell Excel 根据单元格值在特定工作表上复制粘贴范围 - Excel copy-paste range on specific sheet according to cell value 根据单元格值复制行并粘贴到新工作表上 - Copy rows based on cell value and paste on a new sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM