简体   繁体   English

搜索给定值后,将excel中的一行从一张纸复制到另一张纸

[英]Copying a row in excel from one sheet to another after searching for a given value

Disclaimer... I am not looking for someone to code this for me, just point me in the correct direction or give me some examples I can work with. 免责声明...我不是在寻找有人为我编写代码,只是指向正确的方向或提供一些可以使用的示例。

Problem: I have a workbook that has two pages. 问题:我的工作簿有两页。 the first if formatted like this 第一个如果这样格式化

Hostname       Chassis Service Tag Asset Tab   Location    u   
LCLDHV003-25    PE R610 1*V4YQ1     1*1315  D3SF85.08      21
LCMNTYPXYB02    PE R610 BZ00L1      19368   x3SD04.34      36
LEMAILMIG001    PE 1950 9ZVSJ1      12078   x3SE07.12      29
LPASSCDB01-01   PE R710 3XSVH1      11415   P3SD02.22      03

I need to search in in the location field for a given value (example x3SD04) and then insert this row into the second table. 我需要在位置字段中搜索给定值(例如x3SD04),然后将此行插入第二个表中。 I need to have the existing data moved down the page. 我需要将现有数据下移到页面中。

I have seen vlookup index, match and some vba options. 我看过vlookup索引,比赛和一些vba选项。 just that everything I have tried has failed. 只是我尝试过的一切都失败了。

try this: 尝试这个:

Sub test()
    Dim SearchString$, cl As Range, n&
    SearchString = "x3SD04"
    n = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row + 1 'get row for insert copied row
    Set cl = Sheets("Sheet1").Cells.Find(SearchString) 'find range with SearchString
    If Not cl Is Nothing Then 'if SearchString exist in sheet then copy 
        Sheets("Sheet1").Rows(cl.Row).Copy Sheets("Sheet2").Rows(n)
    End If
End Sub

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

相关问题 将excel行从一个工作表复制到另一个工作表 - Copying excel row from one sheet to another 根据单元格值将行从一个 Excel 工作表复制到另一个 - Copying rows from one Excel sheet to another based on cell value 将整个行从一个Excel工作表复制到另一工作表的下一个空行 - Copying entire row from one excel sheet to next empty row of another sheet VBA从一个Excel工作表复制到另一个Excel工作表? - VBA copying from one excel sheet to another excel sheet? Excel宏,用于从一个工作表中的特定字段复制数据,仅保留该值并将其添加到另一工作表中 - Excel macro for copying data from a specific field in one sheet keeping only the value and adding it to another sheet 将Excel中的Excel数据复制到另一个工作表中 - Copying excel data from one sheet into another sheet 库存宏-将信息从一页纸复制到另一页 - Inventory Macro - copying information from one row of sheet to another sheet 将数据从一张纸复制到另一张纸的最后一行 - Copying Data from one sheet to the last row of another sheet VBA Excel将行从一张表复制到另一张中具有特定值的行 - VBA Excel Copying row from one sheet to other that has a specific value in it Excel 2007,根据1列中的值将行从一张工作表复制到另一张工作表 - Excel 2007, Copying rows from one sheet to another based on a value in 1 column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM