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