View Full Version : Import data
onlines
01-15-2009, 09:16 AM
I have scoured the Internet in hopes of finding at least one tutorial on how to import data into Excel into a currently selected Sheet (in this case, sheet labeled with today's date in day-mon-year)
However, i can't find anything, and the macro i created in Excel is absolutely confusing.
Basically, how do you import another excel file, into a currently selected sheet?
Please... PLEASE help
Thank you!
Edit: using vbscript!
onlines
01-15-2009, 11:16 AM
Please? Anybody?
hardlife
01-18-2009, 07:45 AM
Please? Anybody?
Hi, you can try this code
please, do not forget to create or edit "C:\IMPORT\IMPORT.xls"
code will copy all data from first sheet from IMPORT.xls
to first sheet of active workbook.
HAPPY AND SUNNY DAY
Pavel Humenuk
Sub Import()
Sheets(1).Select
Cells.Select
Selection.ClearContents
Application.Goto Reference:="R1C1"
sh = ActiveWorkbook.Name
MsgBox ActiveWorkbook.Path & "\"
MsgBox ActiveWorkbook.FullName
MsgBox ActiveWorkbook.Name
Workbooks.Open FileName:="C:\IMPORT\IMPORT.xls "
' Workbooks.Open FileName:=cesta & "\DATA.xls"
Sheets(1).Activate
Cells.Select
Selection.Copy
Windows(sh).Activate
Sheets(1).Paste
' Sheets("IMPORT").Paste
' ActiveSheet.Paste
Application.CutCopyMode = False
' Selection.ClearContents
Windows("IMPORT.xls").Activate
' ActiveWindow.Close
ActiveWorkbook.Close False
' OR
' Application.DisplayAlerts = False
' ActiveWindow.Close
' Application.DisplayAlerts = True
Windows(sh).Activate
Sheets(1).Select
' Sheets("IMPORT").Select
Application.Goto Reference:="R1C1"
End Sub
OR you can try this interactive mode to open file for import
Sub ImportExceldataFile()
Dim sFile As String
Dim sBook As Workbook
Dim sSheet As Worksheet
Application.ScreenUpdating = False
sFile = Application.GetOpenFilename(FileFilter:="Excel File (*.xls),*.xls")
Set sBook = Workbooks.Open(sFile)
Set sSheet = sBook.Sheets(1)
'Write code to copy data from sSheet here.
'Write code to paste data to template sheet here.
End Sub
mdmackillop
01-18-2009, 05:13 PM
This uses a Userform, together with the OpenFile routine suggested above.
hardlife
01-20-2009, 01:09 PM
This uses a Userform, together with the OpenFile routine suggested above.
I did not expected, such a comfort, what can be done by
short and clear code, Thank you mdmackillop for attachment.
Pavel
hardlife
02-06-2009, 03:28 AM
I did not expected, such a comfort, what can be done by
short and clear code, Thank you mdmackillop for attachment.
HAPPY AND SUNNY DAY TO EVERYBODY
Pavel
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.