• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy data from a closed workbook

Shay A

Member
Hi,
Is it possible to do this if the closed wb is in a different folder ir drive?
I want to copy it to another WB. That might be closed too.

TY,
Shay
 
Try something like that (this code for Mr. Jindon)
Code:
Sub Test()
    Dim wb      As Workbook
    Dim wb2    As Workbook
    Dim ws      As Worksheet
    Dim vFile  As Variant

    Set wb = ActiveWorkbook
    vFile = Application.GetOpenFilename("Excel-files,*.xls*", 1, "Select One File To Open", , False)
    If TypeName(vFile) = "Boolean" Then Exit Sub
    Workbooks.Open vFile
    Set wb2 = ActiveWorkbook
   
    wb2.Worksheets("Sheet1").Cells.Copy wb.Worksheets("Sheet1").Range("A1")
    wb2.Close False
End Sub
 
Back
Top