Hi all,
I am trying to write code to copy data from one workbook to another. What I need is to copy the cell value from column H in the active row to column E in another workbook. All the code I have found copies the entire last row. I managed to find code similar to what I need and manipulate it to copy a single cell. BUT, it seems to always copy the same cell in a particular row over and over. It doesn't copy the cell in the active row. Here is my code. What am I missing?
I am trying to write code to copy data from one workbook to another. What I need is to copy the cell value from column H in the active row to column E in another workbook. All the code I have found copies the entire last row. I managed to find code similar to what I need and manipulate it to copy a single cell. BUT, it seems to always copy the same cell in a particular row over and over. It doesn't copy the cell in the active row. Here is my code. What am I missing?
VBA Code:
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("Log EP VBA template-6-21-20xxxxxxxx.xlsm").Worksheets("Book 1")
Set wsDest = Workbooks("Test List.xlsm").Worksheets("Sheet1")
'1. Find last used row in the copy range based on data in column E
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "E").End(xlUp).Row
'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "E").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("H" & lCopyLastRow).Copy _
wsDest.Range("E" & lDestLastRow)
'Optional - Select the destination sheet
wsDest.Activate