Hi,
Hope someone can help me out on this. I'm trying to copy several columns from 1 workbook (Source File.xls - "sheet1") to another workbook (Target File.xlsm - worksheet ("final").
I need to run a macro to copy specific columns (A, B, C, F, G) from "Source" (but omitting the last 1 row "Not req") to (a, b, c, f, g) on "Target" without overwriting the existing data.
Source File
<tbody>
</tbody>
Target File
<tbody>
</tbody>
I have tried some codes but it doesn't deliver what I want. My apology, don't know how to attach files.
Thanks in advance
Hope someone can help me out on this. I'm trying to copy several columns from 1 workbook (Source File.xls - "sheet1") to another workbook (Target File.xlsm - worksheet ("final").
I need to run a macro to copy specific columns (A, B, C, F, G) from "Source" (but omitting the last 1 row "Not req") to (a, b, c, f, g) on "Target" without overwriting the existing data.
Source File
A | B | C | D | E | F | G |
1111 | 2222 | 3333 | 4444 | 5555 | 6666 | 7777 |
fd | sdfd | dacd | gdd | sfafsd | hgfgh | xdvs |
qe | zccz | gdfv | xbbdbf | vdsv | sdvsd | adsa |
Not req | Not req | Not req | Not req | Not req | Not req | Not req |
<tbody>
</tbody>
Target File
a | a1 | a2 | b | c | c1 | d | e | f | g |
existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data |
existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data |
existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data | existing data |
1111 | 2222 | 3333 | 4444 | 5555 | 6666 | 7777 | |||
fd | sdfd | dacd | gdd | sfafsd | hgfgh | xdvs | |||
qe | zccz | gdfv | xbbdbf | vdsv | sdvsd | adsa |
<tbody>
</tbody>
I have tried some codes but it doesn't deliver what I want. My apology, don't know how to attach files.
Code:
Sub CopySource()
Dim SourceWB As Workbook: Set SourceWB = Workbooks("Source File.xlsx")
Dim TargetWB As Workbook: Set TargetWB = Workbooks("Target File.xlsm")
Dim lr As Long: lr = SourceWB.Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Dim lastr As Long: lastr = TargetWB.Sheets("Final").Cells(Rows.Count, "A").End(xlUp).Row
SourceWB.Sheets("Sheet1").Range("A2:H5000").Copy Destination:=TargetWB.Sheets("Final").Range("A" & lr)
End Sub
Thanks in advance