[英]Search for a value in a column and use the row number obtained to copy a cell
我一直在尝试在列中搜索一个值并使用获得的行号来复制一个单元格。 这是我的代码。
If Trim(FindString) <> "" Then
With Sheets("Details").Range("A:A") 'searches all of column A
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
x = Rng.Row
If Not Rng Is Nothing Then
Sheets("Details").Activate
Sheets("Details").Range("Hx").Copy
Sheets("Report").Activate
.Range("A6").PasteSpecial xlPasteFormats
Else
MsgBox "Unique ID Doesnot Exist! Please Check Again." 'value not found
End If
End With
End If
如何获取 x 的值并使用从搜索中获得的行号引用 H 列中的单元格?
谢谢
结束这个问题:变量不属于引号内。 与&
连接:
Sheets("Details").Range("H" & x).Copy
此外,您需要在If Not Rng Is Nothing Then
之后移动x = Rng.Row
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.