Hi
I have the below code to copy rows with data from one workbook to another ignoring the first two rows as these are header rows however it is only copying column 1. Where am I going wrong?
Sub Export_data()
Dim ws As Worksheet, wb As Worksheet
Set ws = Sheets("Triage")
Set wb = Workbooks("2019 - Couriersheet -copy.xlsx").Worksheets("Triage2")
Dim lr As Long, lrw As Long, lc As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
lrw = ws.Range("A" &Rows.Count).End(xlUp).Row
If lrw > 2 Then
lc= ws.Cells(1, Columns.Count).End(xlToLeft).Column
lr = wb.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range(ws.Cells(3, 1), ws.Cells(lrw, lc)).Copy
wb.Range("A" & lr).PasteSpecial xlPasteValues
ws.Range(ws.Cells(3, 1), ws.Cells(lrw, lc)).EntireRow.Delete
End If
Application.CutCopyMode = False
Workbooks("Job Sheet WIP - copy").Save
Workbooks("2019 - Couriersheet -copy.xlsx").Save
Application.ScreenUpdating = True
Application.EnableEvents = True
MsgBox" Exported ! "
End Sub
I have the below code to copy rows with data from one workbook to another ignoring the first two rows as these are header rows however it is only copying column 1. Where am I going wrong?
Sub Export_data()
Dim ws As Worksheet, wb As Worksheet
Set ws = Sheets("Triage")
Set wb = Workbooks("2019 - Couriersheet -copy.xlsx").Worksheets("Triage2")
Dim lr As Long, lrw As Long, lc As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
lrw = ws.Range("A" &Rows.Count).End(xlUp).Row
If lrw > 2 Then
lc= ws.Cells(1, Columns.Count).End(xlToLeft).Column
lr = wb.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range(ws.Cells(3, 1), ws.Cells(lrw, lc)).Copy
wb.Range("A" & lr).PasteSpecial xlPasteValues
ws.Range(ws.Cells(3, 1), ws.Cells(lrw, lc)).EntireRow.Delete
End If
Application.CutCopyMode = False
Workbooks("Job Sheet WIP - copy").Save
Workbooks("2019 - Couriersheet -copy.xlsx").Save
Application.ScreenUpdating = True
Application.EnableEvents = True
MsgBox" Exported ! "
End Sub