I have two workbooks. Workbook A and Workbook B. I am trying to copy some values from workbook A to Workbook B.
Workbook A:
A B ...... Q
Value
Value
Blank Cell
Value
Value
Blank
Blank
Blank
etc
My range in Workbook A runs from row 9 onwards in column A to Q.
The range in workbook B is the same.
I only want to copy the last used row range, but there may be some blanks in my columns, so it's important it copies all the data to the true last used range/row.
The code i am using produces no error, and nothing gets copied. Please can someone show me where i am going wrong?
Code:
Sub Repair()
UserForm1.Show
End Sub
Sub RunRepair()
Dim x As Workbook
Dim y As Workbook
'## Open both workbooks first:
Set x = Workbooks.Open("B.xlsm")
Set y = Workbooks.Open("A.xlsm")
'Now, copy what you want from x:
x.Sheets("A").Range("A9:Q" & Rows.Count).End(xlUp).Copy
'Now, paste to y worksheet:
y.Sheets("B").Range("A9").PasteSpecial xlPasteValues
y.SaveAs fileName:=Application.ThisWorkbook.Path & "\Food Specials Delivery Tracker TEST.xlsm", FileFormat:=ThisWorkbook.FileFormat
'Close x:
x.Close
y.Close
End Sub