kmmsquared
New Member
- Joined
- Jan 7, 2011
- Messages
- 33
I am new to macros and trying to get this to pull data from another file, but it only imports the data into my personal.xls sheet and not the active sheet. I have checked that it is under a general module and not a worksheet in the personal.xls, but can't get it to work.
Suggestions?
Sub GetDataFromClosedWorkbook()
Dim wb As Workbook
Application.ScreenUpdating = False ' turn off the screen updating
Set Thiswb = Workbooks.Open("FileName", True, True)
' open the source workbook, read only
With ThisWorkbook.Worksheets("Sheet1")
' read data from the source workbook
.Range("A1:C29").Formula = Thiswb.Worksheets("Sheet1").Range("A1:C29").Formula
End With
Thiswb.Close False ' close the source workbook without saving any changes
Set Thiswb = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating
End Sub
Thanks
Suggestions?
Sub GetDataFromClosedWorkbook()
Dim wb As Workbook
Application.ScreenUpdating = False ' turn off the screen updating
Set Thiswb = Workbooks.Open("FileName", True, True)
' open the source workbook, read only
With ThisWorkbook.Worksheets("Sheet1")
' read data from the source workbook
.Range("A1:C29").Formula = Thiswb.Worksheets("Sheet1").Range("A1:C29").Formula
End With
Thiswb.Close False ' close the source workbook without saving any changes
Set Thiswb = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating
End Sub
Thanks