How can I copy two sheet into another WB

alonelove

New Member
Joined
Sep 28, 2017
Messages
45
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
I have file MAIN.xlsm with Macro and two sheets "A1", "A2".
When I Press "Get DATA" button I want to copy data from sheet "G000141" into "A1" and sheet "G000142" into "A2" (G000141, G000142 from another WB)

plz help do that, this's my code but it's not working.

PHP:
Sub Ngoai1()On Error Resume NextDim basebook As StringDim mybook As WorkbookDim fname As StringDim Mypath As String
Application.ScreenUpdating = FalseMypath = Application.ActiveWorkbook.Pathbasebook = ActiveWorkbook.Name
ChDrive MypathChDir Mypath
fname = Application.GetOpenFilename(filefilter:="Execel files (*.xlsx), *.xlsx", Title:="Chon file nguon", MultiSelect:=False)Set mybook = Workbooks.Open(fname)mybook.Worksheets(1).ActivateRange("C19:I785").SelectRange(Selection, Selection.End(xlDown)).SelectSelection.CopyWindows(basebook).ActivateSheet1.SelectRange("A1").SelectActiveSheet.PasteRange("A4").SelectApplication.CutCopyMode = Falsemybook.Close FalseApplication.ScreenUpdating = True
End Sub

Thanks in advanced./.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
2 things
1) you have used PHP tags for your code making it unreadable, please re-post the code using code tags (the # icon)
2) your file is a rar compressed file & I don't have anything to open it (which will probably go for other helpers as well).
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top