Hi Gurus
I'm working on a VBA code that organizes and matchs data from two diferent excels, and produces a new document with the data.
To Match the data, I want to keep the full row of document A, and in front of the last column of this document I Want to insert the match from document B.
I've managed to copy the data from both documents, to diferent sheets of the new document and i can make the data match in "Sheet1", but i cant copy to the place i want.
I've Tried something like
Do While Workbooks(NewWb.Name).Worksheets("Sheet1").Cells(i, 2).Value <> ""
str1 = Workbooks(NewWb.Name).Worksheets("Sheet1").Cells(i, 2).Value
Do While Workbooks(NewWb.Name).Worksheets("Sheet2").Cells(rb, cb).Value <> ""
str2 = Workbooks(NewWb.Name).Worksheets("Sheet2").Cells(rb, cb).Value
If InStr(str2, str1) > 0 Then
Workbooks(NewWb.Name).Worksheets("Sheet2").Rows(rb).EntireRow.Cut Workbooks(NewWb.Name).Worksheets("Sheet1").Cells(rb, column).EntireRow
Else
End If
rb = rb + 1
Loop
rb = user_row
i = i + 1
Loop
The Thing is, instead of pasting the row in front of the pretended column, it substitutes the row from "Sheet1" with the result from the "Sheet2". I think its because I'm using the "EntireRow" Function on this line
Workbooks(NewWb.Name).Worksheets("Sheet2").Rows(rb).EntireRow.Cut Workbooks(NewWb.Name).Worksheets("Sheet1").Cells(rb, column).EntireRow
I've tried using range, but nothing seems to work.
Below an example of the expected result
Sheet1
Product | Component | Description
A | 10 | Thank
B | 20 | You
Sheet2
Product | Price | Time to produce
A | 10 | 10h
B | 20 | 20h
Expected Result
Product | Component | Description | Product | Price | Time to produce
A | 10 | Thank | A | 10 | 10h
B | 20 | You | B | 20 | 20h
Please help!
Best regards and Thanks in Advance
Bookmarks