Bill Williamson
Board Regular
- Joined
- Oct 7, 2019
- Messages
- 124
I know I cant be too far off, but I am getting a runtime error when trying to transfer to an open workbook from a different but now open workbook
Thank you,
Bill Williamson
Rich (BB code):
Sub WeldmentMovingMacro()
' WeldmentMovingMacro Macro
' Enters Data into stainless tracking
' Keyboard Shortcut: Ctrl+w
'Opens Destination file.
Workbooks.Open Filename:= _
"C:\Users\Billw\Desktop\New folder\StainlessDataTest.xlsm"
'Find the last used row in both sheets and copy and paste data below existing data.
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
'Set variables for copy and destination sheets
Set wsCopy = Workbooks(Active.Workbook.xlsx).Worksheets("Export") ' This is where I get the ERROR
Set wsDest = Workbooks("StainlessDataTest.xlsm").Worksheets("All Data")
' Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
' Find first blank row in the destination range based on data in column C
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "C").End(xlUp).Offset(1).Row
'Copy& Paste Data
wsCopy.Range("A2:D" & lCopyLastRow).Copy _
wsDest.Range("C" & lDestLastRow)
End Sub
Thank you,
Bill Williamson
Last edited by a moderator: