copy sheet from other close workbook

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Code:
Sub Button2_Click()
Dim name As String
Cells(1, 2) = "=LEFT(cell(""filename""),FIND(""["",cell(""filename""))-1)"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
name = "C:\SHARING FILES\me\exports\0800"
Workbooks.Open Filename:=Cells(1, 2) & name
Worksheets("Sheet1").Range("A1:P1500").Copy
ActiveWorkbook.Close False
Worksheets("0800").Range("A1").PasteSpecial
End Sub

Good Day ,
Could someone help me on that code given above, why im having error?
Many Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi asyamonique,

Try:

Code:
name = "C:\SHARING FILES\me\exports\0800\"
Workbooks.Open Filename:=name & Cells(1, 2).Text

This assumes Cells (1, 2) contains a valid XL file name

ColinKJ
 
Upvote 0
Hi asyamonique,

Try:

Code:
name = "C:\SHARING FILES\me\exports\0800\"
[COLOR=red]Workbooks.Open Filename:=name & Cells(1, 2).Text[/COLOR]

This assumes Cells (1, 2) contains a valid XL file name

ColinKJ

Hi Colin,
Thanks for ur reply,
Sorry about that but im still having error with that.
Cheers,
 
Upvote 0
asyamonique,

A couple of things to check:

You have got the final backslash after the 0800\ in the path name.
and that the ActiveSheet Cell (1, 2) does have a valid xl file name in it.

Try putting a code stop on the open line, and read the value to ensure it is a valid Path & File Name.

Colin
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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