Find Value in Row, Copy and Paste

ktkelly_1

New Member
Joined
Jun 13, 2019
Messages
17
[FONT=&quot]I am wondering if anyone has ever used the Range.Find macro for finding a certain value storing it as a variable then looking for it again in another file.
[/FONT]

[FONT=&quot]
[/FONT]

[FONT=&quot]So basically there is an ID that I am trying to use as the finding variable and do this for each row. So first ID = Variable go to another workbook and look for that ID and copy two specific columns, lets say C and D then take the data within those two columns and past them in the corresponding workbook of the same row and the finding variable (ID)
[/FONT]

[FONT=&quot]
[/FONT]

[FONT=&quot]
[/FONT]

[FONT=&quot]WORKBOOK 1
[/FONT]

A
B
C
D
1
ID
TITLE
STATUS
OTHER
2
ABC-1234

<tbody>
</tbody>
[FONT=&quot]GO TO WORKBOOK 2, find the id in column a of another workbook
[/FONT]

A
B
C
D
20
ID
TITLE
STATUS
OTHER
21
ABC-1234
EXAMPLETITLE
STATUS1
--------

<tbody>
</tbody>
[FONT=&quot]Select Title and Status of the corresponding row (B21 and C21) and then bring it back to workbook 1
[/FONT]

A
B
C
D
1
ID
TITLE
STATUS
OTHER
2
ABC-1234
EXAMPLETITLE
STATUS1
--------

<tbody>
</tbody>
[FONT=&quot]Please let me know if I have lost everyone, I am not as familiar with looping which is why I hope for this to be a learning experience and for you to have pity on for asking how to create this. Thank you!!

Posted on Microsoft Community : https://answers.microsoft.com/en-us...-3610-4c13-a305-c4243426823c?tm=1562162391506[/FONT]
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,956
Office Version
365
Platform
Windows
A few questions
1) What are the names of the two workbooks & what are the sheet names?
2) Also will both workbooks be open?
3) where will the macro be stored?
 
Last edited:

ktkelly_1

New Member
Joined
Jun 13, 2019
Messages
17
Thank you so much for the quick reply

1. For now let's just call them workbook 1 and workbook 2 as noted above. The file names are a bit more complicated since they change
2. One of the workbooks won't be open, but I can manage that part of the coding wanted to focus on the actual process
3 for now I am running the macro in visual basic, may be moved to a button but unsure for now

Much Appreciated.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,956
Office Version
365
Platform
Windows
This needs to go in Workbook1
Code:
Sub ktkelly1()
   Dim Wbk2 As Workbook
   Dim Ws1 As Worksheet, Ws2 As Worksheet
   Dim Cl As Range
   
   Set Ws1 = ThisWorkbook.Sheets("sheet1")
   Set Wbk2 = Workbooks("Book2.xlsx")
   Set Ws2 = Wbk2.Sheets("Sheet1")
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws2.Range("A2", Ws2.Range("A" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = Cl.Offset(, 1).Resize(, 2)
      Next Cl
      For Each Cl In Ws1.Range("A2", Ws1.Range("A" & Rows.Count).End(xlUp))
         Cl.Offset(, 1).Resize(, 2).Value = .Item(Cl.Value)
      Next Cl
   End With
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,102,889
Messages
5,489,543
Members
407,697
Latest member
Lotte_4

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top