Copy data from closed workbook without opening and into next empty row

luckyduck03

New Member
Joined
Aug 27, 2020
Messages
4
Office Version
  1. 2013
Platform
  1. Windows
I've got this code from another post on this forum that takes data from a closed workbook and copies it to sheet 5 of current workbook, using range A5:F14,:
VBA Code:
Sub AddDataRangeFromClosedWorkbook()

Dim mydata As String
mydata = "='C:\[Closed Workbook.xlsm]MATLIST.XLS'!$A$5:$F$14" '
With ThisWorkbook.Sheets(5).Range("A5:F14")
    .Formula = mydata
    .Value = .Value
End With

End Sub

I'm trying to modify the code to copy a specified range from Closed Workbook.xlsm into sheet 5 of the current workbook, using the next empty row(I'm using Column E to determine the next empty row), below is what I have so far, but this places the value "='C:\[BAH BOM.xlsm]MATLIST.XLS'!$A$5:$F$14" into the next empty row of Column E, I'm trying to get this to grab data in cells A5:F14 from Closed Workbook.xlsm and pasts it into the same columns of A through F, while using Column E to determine the next empty row.

VBA Code:
Sub AddDataRangeFromClosedWorkbook()

Dim mydata As String
mydata = "='C:\[Closed Workbook.xlsm]MATLIST.XLS'!$A$5:$F$14" '
With ThisWorkbook.Sheets(5).Range("E" & Rows.Count).End(xlUp).Offset(1)
    .Formula = mydata
    .Value = .Value
End With

End Sub

Any help is much appreciated.
Mark
Office 2013
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
How about
VBA Code:
Sub AddDataRangeFromClosedWorkbook()

Dim mydata As String
mydata = "='C:\[Closed Workbook.xlsm]MATLIST.XLS'!$A$5:$F$14" '
With ThisWorkbook.Sheets(5).Range("E" & Rows.Count).End(xlUp).Offset(1,-4)
    .Formula = mydata
    .Value = .Value
End With

End Sub
 
Upvote 0
How about
VBA Code:
Sub AddDataRangeFromClosedWorkbook()

Dim mydata As String
mydata = "='C:\[Closed Workbook.xlsm]MATLIST.XLS'!$A$5:$F$14" '
With ThisWorkbook.Sheets(5).Range("E" & Rows.Count).End(xlUp).Offset(1,-4)
    .Formula = mydata
    .Value = .Value
End With

End Sub
Thank you for the suggestion, however it's still returning the formula ='C:\[Closed Workbook.xlsm]MATLIST.XLS'!$A$5:$F$14 into the next empty row instead of the actual data from cells:A5:F14 from Closed Workbook.xlsm. Only this time it's putting in on the A column, which is the correct column this data starts in.
Do I need to change how I collect the data from the MATLIST.XLS sheet of Closed Workbook.xlsm?

Mark
Office 2013
 
Upvote 0
How about
VBA Code:
Sub AddDataRangeFromClosedWorkbook()

Dim mydata As String
mydata = "='C:\[Closed Workbook.xlsm]MATLIST.XLS'!A5" '
With ThisWorkbook.Sheets(5).Range("E" & Rows.Count).End(xlUp).Offset(1,-4).Resize(10,6)
    .Formula = mydata
    .Value = .Value
End With

End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,956
Latest member
JPav

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