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