Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing Multiple files nearly there

First of all I rin this Macro: -

Sub ListFiles()
F = Dir("C:\*.XLS")
Do While Len(F) 0
ActiveCell.Formula = F
ActiveCell.Offset(1, 0).Select
F = Dir()
Loop
End Sub

This list the filenames in the directory.


Now I want this macro to copy the information from the file name i
cell A1.
I tried this but there was no luck: -

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 15/01/2004 by Ian
'

Workbooks.Open Filename:= (A1)
Range("A:B").Copy Destination:=Workbooks("Book1").Range("A:B")
MsgBox ("Completed Copying")
End Sub

ANY IDEA HOW TO MAKE THIS REFERENCE LOOK AT CELL A1 as a file name

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Importing Multiple files nearly there

Sub Macro1()
Dim sName as String
sName = Dir("C:\Data\*.xls")
do while sName < ""
Workbooks.Open Filename:=sName
set rng = Workbooks("Book1.xls"). _
Worksheets(1).Cells(1,256).End(xltoleft)
if not isempty(rng) then _
set rng = rng.offset(0,1)

ActiveWorkbook.columns("A:B").copy _
Destination:=rng
Activeworkbook.Close SaveChanges:=False
sName = dir()
Loop
End Sub


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 15/01/2004 by Ian
'

Workbooks.Open Filename:= Range("A1").Value
Range("A:B").Copy Destination:=Workbooks("Book1").Range("A:B")
MsgBox ("Completed Copying")
End Sub

--
Regards,
Tom Ogilvy

ianripping wrote in message
...
First of all I rin this Macro: -

Sub ListFiles()
F = Dir("C:\*.XLS")
Do While Len(F) 0
ActiveCell.Formula = F
ActiveCell.Offset(1, 0).Select
F = Dir()
Loop
End Sub

This list the filenames in the directory.


Now I want this macro to copy the information from the file name in
cell A1.
I tried this but there was no luck: -

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 15/01/2004 by Ian
'

Workbooks.Open Filename:= (A1)
Range("A:B").Copy Destination:=Workbooks("Book1").Range("A:B")
MsgBox ("Completed Copying")
End Sub

ANY IDEA HOW TO MAKE THIS REFERENCE LOOK AT CELL A1 as a file name?


---
Message posted from http://www.ExcelForum.com/



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
Importing multiple files Tommy Excel Discussion (Misc queries) 1 February 19th 07 03:00 PM
Importing multiple files Joel Excel Discussion (Misc queries) 0 February 19th 07 11:46 AM
importing multiple .dat files! via135 Excel Worksheet Functions 0 March 29th 06 08:09 PM
Importing from multiple Excel files Tired of wasting time Excel Discussion (Misc queries) 2 September 21st 05 08:22 PM
Importing Multiple Data Files steve Excel Programming 0 July 24th 03 09:26 PM


All times are GMT +1. The time now is 08:00 AM.

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"