Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import all txt files macro Eva Excel Worksheet Functions 4 December 2nd 09 09:19 PM
Import 2 text files into 2 separate columns? tcurrier Excel Discussion (Misc queries) 3 February 11th 06 07:13 PM
Import CSV files using Macro Mintz87 New Users to Excel 3 August 29th 05 09:48 PM
Import csv files, delete rows, arrange columns .... xadnora Excel Programming 8 April 11th 05 04:48 PM
Import multiple files macro can't find files Steven Rosenberg Excel Programming 1 August 7th 03 01:47 AM


All times are GMT +1. The time now is 02:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"