Hi,
Have the code below that I want to copy from one workbook to another is doing but the problem put all in the wrong rows, not according to the cell saying in the code is copying everything but staring in row 42 in right columns.
here is the code:
Putting all of t them row 42:
Thank you,
Have the code below that I want to copy from one workbook to another is doing but the problem put all in the wrong rows, not according to the cell saying in the code is copying everything but staring in row 42 in right columns.
here is the code:
VBA Code:
Sub Copyfrom_EXP12017_APINVOICE()
Dim Wb1, Wb2 As Workbook
Dim ws1, ws2 As Worksheet
Dim Row, i, j As Long
'Set Variables
Set Wb1 = Workbooks.Open("C:\Users\jose.rossi\Desktop\Excel Files\EXPENSES_TESTING\EXP12017_IMPORT\EXP12017.xlsm")
Set Wb2 = Workbooks.Open("C:\Users\jose.rossi\Desktop\Excel Files\EXPENSES_TESTING\EXPENSE_IMPORT.xlsm")
Set ws1 = Wb1.Worksheets("EXP12017")
Set ws2 = Wb2.Worksheets("EXPENSE")
Row = ws1.Range("A2").End(xlDown).Row
j = 2
'Stop Screen Updating
' Application.ScreenUpdating = False
'Application.EnableEvents = False
'Application.DisplayStatusBar = False
'Application.Echo False
'Copy Column A
For i = 2 To Row
ws1.Range("A" & i).Copy
ws2.Activate
ws2.Range("A4" & j).Select
ActiveCell.PasteSpecial xlPasteValues
ws1.Activate
j = j + 1
Next i
'Copy Column B
j = 2
For i = 2 To Row
ws1.Range("B" & i).Copy
ws2.Activate
ws2.Range("B4" & j).Select
ActiveCell.PasteSpecial xlPasteValues
ws1.Activate
j = j + 1
Next i
'Copy Column F
'j = 2
'For i = 2 To Row
'ws1.Range("F" & i).Copy
'ws2.Activate
'ws2.Range("B19" & j).Select
'ActiveCell.PasteSpecial xlPasteValues
'ws1.Activate
'j = j + 1
'Next i
'Copy Column I
j = 2
For i = 2 To Row
ws1.Range("I" & i).Copy
ws2.Activate
ws2.Range("A19" & j).Select
ActiveCell.PasteSpecial xlPasteValues
ws1.Activate
j = j + 1
Next i
'Copy Column J
j = 2
For i = 2 To Row
ws1.Range("J" & i).Copy
ws2.Activate
ws2.Range("C4" & j).Select
ActiveCell.PasteSpecial xlPasteValues
ws1.Activate
j = j + 1
Next i
'Copy Column K
j = 2
For i = 2 To Row
ws1.Range("K" & i).Copy
ws2.Activate
ws2.Range("D4" & j).Select
ActiveCell.PasteSpecial xlPasteValues
ws1.Activate
j = j + 1
Next i
'Close Wb1
'Wb1.Close
'Cancel Variables
Set Wb1 = Nothing
Set Wb2 = Nothing
Set ws1 = Nothing
Set ws1 = Nothing
Row = 0
i = 0
j = 0
'Restore Screen Updating
'Application.ScreenUpdating = True
'Application.EnableEvents = True
End Sub
Putting all of t them row 42:
EXPENSE_IMPORT.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
42 | EXP12017 | 45047 | 133.76 | 6.69 | ||
43 | EXP12017 | 45047 | 8.93 | 0.18 | ||
44 | EXP12017 | 45047 | 58.45 | 1.15 | ||
45 | EXP12017 | 45047 | 14.35 | 0.28 | ||
46 | EXP12017 | 45047 | 7.4 | 0.15 | ||
47 | EXP12017 | 45047 | 19.73 | 0.39 | ||
48 | EXP12017 | 45047 | 148.63 | 7.43 | ||
EXPENSE |
Thank you,