Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba macro to define 3 files, and import columns
I am new to the world of macros and vba
I need a code that allows a user to define three different files and import some colums from each into a sheet set up to make graphs from the numbers. Any help would be much appreciated |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba macro to define 3 files, and import columns
Miree,
If the files are in the same folder, something like this, which copies 3 columns (A1:C10) from each file and pastes them in B2:D11,E2:G11, and H2:J11, and on... Sub OpenMultipleUserSelectedFiles() Dim FileArray As Variant Dim myBook As Workbook Dim myTargetBook As Workbook Dim mySht As Worksheet Dim myCol As Integer Set myTargetBook = ActiveWorkbook myCol = 1 FileArray = Application.GetOpenFilename(MultiSelect:=True) If IsArray(FileArray) Then For i = LBound(FileArray) To UBound(FileArray) Set myBook = Workbooks.Open(FileArray(i)) myBook.Worksheets(1).Range("A1:C10").Copy _ myTargetBook .Worksheets(1).Range("A2").Offset(0, myCol) myCol = myCol + 3 myBook.Close False Next i End If End Sub -- HTH, Bernie MS Excel MVP "Miree" wrote in message ... I am new to the world of macros and vba I need a code that allows a user to define three different files and import some colums from each into a sheet set up to make graphs from the numbers. Any help would be much appreciated |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Import all txt files macro | Excel Worksheet Functions | |||
Import 2 text files into 2 separate columns? | Excel Discussion (Misc queries) | |||
Import CSV files using Macro | New Users to Excel | |||
Import csv files, delete rows, arrange columns .... | Excel Programming | |||
Import multiple files macro can't find files | Excel Programming |