I have a workbook which I have downloaded and have tried to write code to open the source workbook and then to copy the data from sheet1 (not necessarily named sheet1) in the source workbook into the destination workbook in the sheet next to the sheet named “Pivot Table”
The code allows me to select the source workbook, however the folowing code is highlighted
nb.Sheets(“Sheet1”).Copy After:=Workbooks(“BR1 Vat Report Macro.xlsm”).Sheets(“Pivot Table”)
See full code below
Sub Open_Workbook()
Dim nb As Workbook, tw As Workbook, ts As Worksheet
a = Application.GetOpenFilename
If a = False Or IsEmpty(a) Then Exit Sub
With Application
.ScreenUpdating = False
End With
Set tw = ThisWorkbook
Set ts = tw.ActiveSheet
Set nb = Workbooks.Open(a)
nb.Sheets(“Sheet1”).Copy After:=Workbooks(“BR1 Vat Report Macro.xlsm”).Sheets(“Pivot Table”)
End Sub
Your assistance in correcting this will be most appreciated