Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi guys,
The piece of code that i am using here, imports data from 3 externa files into one worksheet. Could someone tell me how the code would loo if i were to put the data from each file into seperate worksheets? Sub Open3_v2() Dim i As Integer 'Clear out the existing data Worksheets("Data").UsedRange.EntireRow.Delete 'Get the 3 data files For i = 1 To 3 OpenFile Next End Sub Sub OpenFile() Dim strFile As String Dim wbkData As Workbook 'Locate the file - quit if user presses cancel strFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls" , "Select file", "OK") If Dir(strFile) = "" Then Exit Sub 'Open the file Set wbkData = Workbooks.Open(strFile) 'Copy all the data from the one sheet wbkData.Activate ActiveSheet.UsedRange.Select Selection.Copy 'Come back to this workbook and paste the data at the bottom ThisWorkbook.Activate Worksheets("Data").Activate Cells(ActiveSheet.UsedRange.Rows.Count + 1, 1).Select ActiveSheet.Paste 'Close the data file wbkData.Close False 'Free up used space in memory Set wbkData = Nothing End Sub Thanks in advance, Cathal -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
add two cells from seperate work sheets into a cell on seperate wo | Excel Worksheet Functions | |||
Splitting data from sheets into seperate workbooks based on formul | Excel Worksheet Functions | |||
Auto insert data to seperate sheets? | New Users to Excel | |||
Import data into seperate columns | Excel Discussion (Misc queries) | |||
Vlook up for matching data in two seperate sheets | Excel Discussion (Misc queries) |