Logit
Well-known Member
- Joined
- Aug 31, 2016
- Messages
- 5,031
- Office Version
- 2019
- 2007
- Platform
- Windows
I'm wanting to search a numerical term WB1 Column B, that might be found in WB2 Column B. If found, copy data from same row Column E and paste same in WB 1 Column E.
There are links below to download both example workbooks with only 20 rows of data as a sample.
Here is a macro I've tried but it probably needs to be edited for efficiency. My computer runs Win 10/64 bit with 16 gb of RAM ... however, it strains to loads both workbooks and perform the search/copy/paste actions. Any edits to the following macro to make it a lot more efficient with my computer's resources is greatly appreciated.
WB 1 : https://share.eu.internxt.com/d/sh/file/63f79da8-8bba-4da7-b05a-ed490167cac3/616323cfdd4ff06bc873a5647c6e03767b0496a6becd7245119ee3b21eba206d
WB 2 : WB 2 : https://share.eu.internxt.com/d/sh/file/6170755e-8cdb-40a7-8cae-03b404a0b070/39283917b47a0715c70fd46ac9e4ec6d9899d37b122787cef43a94a291e7d1c0
Any assistance is greatly appreciated.
There are links below to download both example workbooks with only 20 rows of data as a sample.
Here is a macro I've tried but it probably needs to be edited for efficiency. My computer runs Win 10/64 bit with 16 gb of RAM ... however, it strains to loads both workbooks and perform the search/copy/paste actions. Any edits to the following macro to make it a lot more efficient with my computer's resources is greatly appreciated.
VBA Code:
Sub CopyDataBasedOnUniqueTerms()
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim uniqueTerm As String
Dim lastRow As Long, searchRow As Long
Dim foundCell As Range
Set wb1 = Workbooks("WB 1.xlsb")
Set wb2 = Workbooks("WB 2.xlsb")
Set ws1 = wb1.Sheets(1)
lastRow = ws1.Cells(ws1.Rows.Count, "B").End(xlUp).Row
For searchRow = 1 To lastRow
uniqueTerm = ws1.Cells(searchRow, "B").Value
Set foundCell = Nothing
For Each ws2 In wb2.Sheets
Set foundCell = ws2.Columns("B").Find(What:=uniqueTerm, LookIn:=xlValues, LookAt:=xlPart)
If Not foundCell Is Nothing Then
ws1.Cells(searchRow, "E").Value = ws2.Cells(foundCell.Row, "E").Value
Exit For
End If
Next ws2
Next searchRow
End Sub
WB 1 : https://share.eu.internxt.com/d/sh/file/63f79da8-8bba-4da7-b05a-ed490167cac3/616323cfdd4ff06bc873a5647c6e03767b0496a6becd7245119ee3b21eba206d
WB 2 : WB 2 : https://share.eu.internxt.com/d/sh/file/6170755e-8cdb-40a7-8cae-03b404a0b070/39283917b47a0715c70fd46ac9e4ec6d9899d37b122787cef43a94a291e7d1c0
Any assistance is greatly appreciated.