everyone. My goal is to get a pop-up window to pull a data from different workbook and copy the whole sheet from the first sheet in the pulled workbook and paste it into sheet2 of the original workbook. I need help with last line. It doesn't seem to work as I am new to VBA programming. Also, is it possible to open not only .xlsx but also .xls file type as well? One more thing, is it possible copy/paste without having to open a different file? like disabling event enabler..
Option Explicit
Sub test()
Dim wb As Workbook, wb2 As Workbook
Dim ws As Worksheet
Dim vFile As Variant
'Set source workbook
Set wb = ActiveWorkbook
'Open the target workbook
vFile = Application.GetOpenFilename("Excel-files,*.xlsx", _
1, "Select One File To Open", , False)
'if the user didn't select a file, exit sub
If TypeName(vFile) = "Boolean" Then Exit Sub
Workbooks.Open vFile
'Set targetworkbook
Set wb2 = ActiveWorkbook
'For instance, copy data from a range in the first workbook to another range in the other workbook
' wb.Worksheets(1).Cells.Copy _
' Destination:=newworksheet.Cells
wb.Worksheets(2).Range("C3:D4").Value = wb2.Worksheets(1).Range("A1:B2").Value
End Sub