I am trying to paste values from another excel worksheet but my code below keeps returning an error. What am i doing wrong ?
Set tempWB = Application.Workbooks.Open(vrtSelectedItem) 'This OPENS the reference workbook
Sheets("Portfolio Worksheet 8.8").Select 'SELECT A SHEET if you need to
Range("B16:B30").Select 'select SOME RANGE
Selection.Copy 'COPY SOME RANGE
mainWB.Activate 'activate your main workbook
Sheets("Sheet1").Select 'select target sheet
Range("C20").Select 'select target cell
ActiveSheet.PasteSpecial xlPasteValues 'paste the data from the reference worksheet
tempWB.Save 'save and close the reference workbook
tempWB.Close