如果单元格C2值在P2:P25范围内,则将列T的匹配行中的值粘贴到列N的同一行中。
查看here图片。
答案 0 :(得分:1)
一种方式,作为独立示例编写,并假设数据在Sheet1上并传输第一个匹配项。请注意,此示例中没有错误检查/处理。
Sub xferNum()
Dim ws As Worksheet
Dim srow As Long, erow As Long, scol As Long, srchcol As Long
Dim rsltcol As Long, lucol As Long
Dim fndNo As Range, c As Range, lookrng As Range
Set ws = Sheets("Sheet1")
srow = 2
scol = 3
srchcol = 16
lucol = 20
rsltcol = 14
With ws
erow = .Cells(.Rows.Count, scol).End(xlUp).Row
Set lookrng = .Range(.Cells(srow, scol), .Cells(erow, scol))
For Each c In lookrng
Set fndNo = Columns(srchcol).Find(what:=c.Value)
If Not fndNo Is Nothing Then
.Cells(c.Row, rsltcol).Value = fndNo.Offset(0, lucol - fndNo.Column).Value
End If
Next c
End With
End Sub
答案 1 :(得分:0)
在单元格N2中输入以下公式:= IF(C2 = P2,T2,“”)
然后将单元格N2向下突出显示为N25并填充。 (CTRL + D)。