Hello,
I am having issues with a code that will copy data from another open workbook (the name of the other workbook will always be 'Book1') and paste it back in the original workbook.
1. go to 'Book1' as it will be open on the computer
2. copy entire region of data from A2 down (it will be a lot of data)
3. Paste data back in original workbook on sheet called 'Sheet4' as values
4. close 'Book1' without saving
I cant seem to get it to see that wb1 is just the active workbook? I have tried it as activeworkbook or thisworkbook it errors out saying 'Object variable or With block variable not set'.
Sub refernceworkbook()
Dim wb1 As Workbook
Dim wb2 As Workbook
wb1 = ActiveWorkbook
wb2 = Workbooks("Book1")
wb2.Sheets(1).Range("a2").CurrentRegion.Copy
wb1.Worksheets("Sheet4").Range("A2").PasteSpecial Paste:=xlPasteValues
wb2.Close
End Sub
Any help would be greatly appreciated.
Bookmarks