Copy sheet from closed Workbook to another workbook

Status
Not open for further replies.

Kurt

Well-known Member
Joined
Jul 23, 2002
Messages
1,664
I am trying a new set of code:

Code:
Sub GetDataClosedBook()

Dim src As Workbook
'location of the file and data to copy

Set src = Workbooks.Open("C:\\Documents\Data Calc Formulas v 1.13b.xlsb", True, True)
'bring to this workbook

ThisWorkbook.Activate

Worksheets("RawData").Range("A1:S29,089").Formula = src.Worksheets("C:\Documents\Raw Reports - All Of Them - xxxx Copy.xlsx").Range("A1:C2").Formula

End Sub
'https://www.youtube.com/watch?v=5as4AfpqWBA

The code keeps stoping on the Set src = Workbooks line

Any Ideas?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
incorrect
Code:
Set src = Workbooks.Open("C:[COLOR=#ff0000]\\[/COLOR]Documents\Data Calc Formulas v 1.13b.xlsb", True, True)
correct
Code:
Set src = Workbooks.Open("C:[COLOR=#ff0000]\[/COLOR]Documents\Data Calc Formulas v 1.13b.xlsb", True, True)
 
Upvote 0
incorrect
Code:
Set src = Workbooks.Open("C:[COLOR=#ff0000]\\[/COLOR]Documents\Data Calc Formulas v 1.13b.xlsb", True, True)
correct
Code:
Set src = Workbooks.Open("C:[COLOR=#ff0000]\[/COLOR]Documents\Data Calc Formulas v 1.13b.xlsb", True, True)

I have already tried that! The code still stops!!
 
Upvote 0
What does the message box return when you run this?

Code:
Sub IsFileThere()
    Dim msg As String, fPath As String
    fPath = "C:\Documents\Data Calc Formulas v 1.13b.xlsb"

    If Dir(fPath, vbDirectory) = vbNullString Then msg = "NOT "
    MsgBox "File " & fPath & vbCr & msg & "FOUND"        
End Sub
 
Last edited:
Upvote 0
What does the message box return when you run this?

Code:
Sub IsFileThere()
    Dim msg As String, fPath As String
    fPath = "C:\Documents\Data Calc Formulas v 1.13b.xlsb"

    If Dir(fPath, vbDirectory) = vbNullString Then msg = "NOT "
    MsgBox "File " & fPath & vbCr & msg & "FOUND"        
End Sub

Thanks for this snippet of code Yongle.

I get the error message the file is not found!

I have tried several iterations of the file name path.

What else can I check for?
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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