(a bit similar to the xWizardx post re: calling date data; ultimately I could not find solution from this thread)
Workbook A contains, among a total of 20-30 named ranges, the named range "MyName".
I would like to, upon command button click (which I'm good with), read this file, copy the data ("MyName" and the others), and return the data to a specified worksheet ("DataDump" - Cell A1 filling down) in my Active Workbook.
I am currently working with / attempting to modify the following:
Sub ImportData()
'
' Import Macro
'
Dim strWorkbookName As String
Dim strImportFileName As String
pAbort = False
'Get the current workbook name
strWorkbookName = ActiveWorkbook.Name
' Open file for import - allows user to specify file containing the data needed.
FileName = Application.GetOpenFileName(FileFilter:="Excel Files (*.xls),*.xls", Title:="Select Data")
If FileName = False Then
MsgBox "No file was selected! Exiting..."
Sheets(ActiveSheet).Select
pAbort = True
Exit Sub
End If
Application.ScreenUpdating = False
Workbooks.Open FileName
strImportFileName = ActiveWorkbook.Name
Range("MyName").Select
Selection.Copy
Windows(strWorkbookName).Activate
Sheets("DataDump").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Windows(strImportFileName).Activate
Application.CutCopyMode = False
ActiveWorkbook.Close
MsgBox ("Data successfully imported")
End Sub
This code does successfully retrieve/paste the "MyName".
1. Is there a way to collect all the data at once, and then paste all the data at once?
2. Is there a way to do this without actually opening the queried file?
3. If not, is there a way to override the 'must save prompt' of the queried workbook after
Thanks!! ~AS
Bookmarks