May 11, 2019
Hi,
I have a VBA project in which I want to copy a range created by vlookup to another workbook, but I can only get the result #####. It is only pasting the vlookup formula, and not the values.
Im sure this is an easy fix, but I cant seem to find it. below is the sub.
if you guys could help it would be awesome.
Sub Copy_Paste_Below_Last_Cell()
'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("GMD Fee Calculator V03.xlsm").Worksheets("Lookup")
Set wsDest = Workbooks("GMD_Calculator_Journal.xlsx").Worksheets("Sheet1")
'1. Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "F").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, "A").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("F2:L2" & lCopyLastRow).Copy _
wsDest.Range("A" & lDestLastRow)
End Sub
1 Guest(s)