它可能已经在这里了,我已经错过了,但是我在解决如何将代码从粘贴到最后一行更改为粘贴到特定行方面遇到困难。
每个数据集在A列中都有一个唯一的编号。 我需要将Array粘贴到与数据条目Sheet上的唯一引用匹配的行中。
因此,如果数据输入表(输入操作)在单元格C3中具有“ 123”,我需要它查看数据库(RAW DATA)并在列A中找到带有“ 123”的行,并将数组粘贴到此行。
我以前只粘贴到最后一行,不知道如何更改以下代码来完成我需要的工作。
Dim vCopy, i As Long, rPaste As Range
vCopy = Array("C3", "C5", "Q26", "C7", "C9", "Q26", "C11", "C13", "C15", "G13", "G3", "C17", "G7", "G9", "K3", "G11", "K9")
Set rPaste = Sheets("RAW DATA").Cells(Rows.count, 1).End(xlUp)(2)
For i = LBound(vCopy) To UBound(vCopy)
rPaste.Value = Sheets("Enter Action").Range(vCopy(i)).Value
Set rPaste = rPaste.Offset(, 1)
Next i
答案 0 :(得分:0)
您可以使用Find
:
Dim vCopy, i As Long, f As Range, lookFor
vCopy = Array("C3", "C5", "Q26", "C7", "C9", "Q26", "C11", "C13", "C15", _
"G13", "G3", "C17", "G7", "G9", "K3", "G11", "K9")
lookFor = Sheets("Enter Action").range("c3").value
Set f = Sheets("RAW DATA").Columns(1).find(lookFor, lookat:=xlWhole)
If not f is nothing then
For i = LBound(vCopy) To UBound(vCopy)
f.Offset(0, i).Value = Sheets("Enter Action").Range(vCopy(i)).Value 'fixed#2
Next i
End If