我有2张。我想将sheet2的A1与Sheet1的A:A进行比较,如果匹配,则将第3张B1的A1最后一行的值编入索引(所以我对索引感到困惑)查找最后一行值的部分。)所以这需要为近1000个项目完成。那么这个任何vba OR公式?
答案 0 :(得分:1)
好的,这对我来说只是做XXX数据值的测试。您可以为YYY修改它。
Option Explicit
Sub CompareAndCopyData()
Dim DataWorkSheet As Worksheet
Set DataWorkSheet = ThisWorkbook.ActiveSheet
With DataWorkSheet
Dim SearchRange As Range
Set SearchRange = .Range("E2:E5")
Dim SearchText As String
SearchText = .Range("E2").Value
Dim SearchResult As Range
Set SearchResult = SearchRange.Find(What:=SearchText)
Dim LastColumn As Long
LastColumn = .Cells(SearchResult.Row, .Columns.Count).End(xlToLeft).Column
.Cells(8, "F").Value = .Cells(SearchResult.Row, LastColumn).Value
End With
End Sub