
Originally Posted by
antibudger
I have multiple sheets in my workbook. In sheet 2, I would like to identify a text name in column B, and if found I would like to copy the value from its corresponding row in column A to sheet 1 column B when the text is identified in sheet 1 column A. In sheet 1, the text will only appear once. In sheet 2, the text will likely occur many times.
Andrea,
If by identify you mean select:
Sub test()
Dim lngR As Long
lngR = Application.Match(ActiveCell.Value, Sheets("Sheet1").Range("A:A"), False)
Sheets("Sheet1").Range("B:B").Cells(lngR).Value = ActiveCell.Offset(0, -1).Value
End Sub
If by identify you mean something else, post back.
Or you could just use a formula in column B of Sheet1 that will pull the last (lowest down the sheet) entry from Sheet2, base on the value in A2 - this needs to be array-entered (enter using Ctrl-Shift-Enter) and skip the macro altogether.
Formula:
=INDEX(Sheet2!$A$1:$A$1000,MAX(IF(Sheet2!$B$1:$B$1000=Sheet1!A2,ROW($A$1:$A$1000))))
Bookmarks