• 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.

Open up folder-select a file-copy a particular sheet

Mr.Karr

Member
Hello,

Can you please provide a code snippet for below;
1. Open up file explorer
2. Select a file
3. Copy arraysheets("Sheet1" , "Sheet2")

and move to the source workbook.

Any help would be much appreciated.

Thanks a lot in advance,
Karthik
 
will this help?

Code:
Const fromFile = "C:\Users\karthikeyan\Desktop\Automation_Russia\ME Revenue File.xlsm"


Dim srcBook As Workbook
Set srcBook = Application.Workbooks.Open(fromFile, _
    UpdateLinks:=False, _
    ReadOnly:=True, _
    AddToMRU:=False)


    srcBook.Sheets("A.4 Engagement Summary").Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)


srcBook.Close False

Modifications:

1. Instead having a path by default, pls set a file explorer to open & select a file

2. Apart from that, srcBook.Sheets, please make it array to accommodate multiple sheets.

Thanks again!
 
Code:
Else
vfilename = Split(sImportFile, "\")
sFile = vfilename(UBound(vfilename))
Application.Workbooks.Open Filename:=sImportFile

Set wbBk = Workbooks(sFile)
With wbBk
If SheetExists("A.4 Engagement Summary") Then
Set wsSht = .Sheets("A.4 Engagement Summary")
wsSht.Copy before:=sThisBk.Sheets("Sheet1")
Else
MsgBox "There is no sheet with name :A.4 Engagement Summary in:" & vbCr & .Name
End If
wbBk.Close SaveChanges:=False
End With
End If

managed to found this online.
Can anyone help to have this array below;

I need to have array("Sheet1" , "Sheet2") for an example

If SheetExists("A.4 Engagement Summary") Then
Set wsSht = .Sheets("A.4 Engagement Summary")
wsSht.Copy before:=sThisBk.Sheets("Sheet1")
 
Back
Top