Results 1 to 4 of 4

Thread: Find Value in Row, Copy and Paste
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jun 2019
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Find Value in Row, Copy and Paste

    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.



    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)





    WORKBOOK 1

    A B C D
    1 ID TITLE STATUS OTHER
    2 ABC-1234
    GO TO WORKBOOK 2, find the id in column a of another workbook

    A B C D
    20 ID TITLE STATUS OTHER
    21 ABC-1234 EXAMPLETITLE STATUS1 --------
    Select Title and Status of the corresponding row (B21 and C21) and then bring it back to workbook 1

    A B C D
    1 ID TITLE STATUS OTHER
    2 ABC-1234 EXAMPLETITLE STATUS1 --------
    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/...=1562162391506

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    29,068
    Post Thanks / Like
    Mentioned
    483 Post(s)
    Tagged
    48 Thread(s)

    Default Re: Find Value in Row, Copy and Paste

    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 by Fluff; Jul 3rd, 2019 at 11:13 AM.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    New Member
    Join Date
    Jun 2019
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Find Value in Row, Copy and Paste

    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.

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    29,068
    Post Thanks / Like
    Mentioned
    483 Post(s)
    Tagged
    48 Thread(s)

    Default Re: Find Value in Row, Copy and Paste

    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
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •