Code To Find Info From Sheet 2

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,786
Office Version
  1. 365
Platform
  1. Windows
I have a list of numbers on sheet 1 starting in A2. What I need the code to do is look for that number that could be anywhere on sheet 2 and put what it is in the adjacent cell to it in column 'B'.

i.e ABC123 may be in A2 on sheet 1 and the sama data may be on sheet 2 in cell J14 and I want it to take what is next to that number in K14 and put it in B2. Thanks.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
No because like I said it could be anywhere on sheet 2, where I may have 50 columns and 10000 rows for it to look at.
 
Upvote 0
With Sheet1 as the active sheet, see if this macro does what you want:


Code:
Sub Test1()
Application.ScreenUpdating = False
Dim cell As Range, varFind As Variant
With Worksheets("Sheet2")
For Each cell In Columns(1).SpecialCells(2)
Set varFind = .Cells.Find(What:=cell.Value, LookIn:=xlFormulas, LookAt:=xlWhole)
If Not varFind Is Nothing Then _
cell.Offset(0, 1).Value = .Cells(varFind.Row, varFind.Column + 1).Value
Set varFind = Nothing
Next cell
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,557
Messages
6,179,508
Members
452,918
Latest member
Davion615

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top