I am hoping you all can help. I am trying to modify a previously working sub to Copy and Paste a SourceRange into a named table. The table used to be on its own sheet which made the VBA easy but now it has been requested to move the table to a central location sharing a sheet with other tables.
Code I currently have is below, I cannot set the Destination range. Any help would be appreciated as I will use this multiple times in this workbook.
Code I currently have is below, I cannot set the Destination range. Any help would be appreciated as I will use this multiple times in this workbook.
VBA Code:
Sub MonthyVendorMove()
Dim sourceRange As Range
Dim destrange As Range
Dim LR As Integer
Dim MVTable As ListObject
Set MVTable = Workbooks("On Time Delivery Current.xlsm").Sheets("OTD Tables").ListObjects("MonthlyVendor")
'Calls function to find Last Row on Named Table MonthlyVendor
LR = MVTable.Range.Rows.Count
'ERROR here Sets Destination Range, Where info will be going
Set destrange = MVTable.Range("AG" & LR)
'Sets Range to be Copied
Set sourceRange = Workbooks("On Time Delivery Current.xlsm").Sheets("Weekly Shipments Pivot").Range("A25:C25")
'Copy the Range set in line before
sourceRange.Copy
'Pastes only Values
destrange.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
MsgBox ("Done")
End Sub