Solved

Moving data across files

Posted on 2000-03-02
4
139 Views
Last Modified: 2010-05-02
I have a whole bunch of Excle spreadsheets in a directory. They are all of the same format. I don't use any standard naming conventions. I need to copy some of this data onto a new spreadsheet.

Is there some way that I can say:

for every file in directory 12345
open the file
select data in j1:j100
paste the data into column a(or b, c, etc) of my new file
open the next source file
0
Comment
Question by:panikos
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
ture earned 100 total points
ID: 2576456
Panikos,

This Excel VBA procedure should do exactly what you ask for.

Sub HelpPanikos()
  Dim rngDest As Range
  Dim strPath As String
  Dim strFileName As String
 
  Set rngDest = ThisWorkbook.Sheets("Sheet1").Range("A1")
  strPath = "c:\12345\"
  strFileName = Dir(strPath & "*.xls")
 
  Do Until strFileName = ""
    With Workbooks.Open(strPath & strFileName)
      .Sheets("Sheet1").Range("J1:J100").Copy rngDest
      .Close SaveChanges:=False
    End With
    strFileName = Dir()
    Set rngDest = rngDest.Offset(0, 1)
  Loop
End Sub

Ture Magnusson
Karlstad, Sweden
0
 

Author Comment

by:panikos
ID: 2576524
Thank you very much Ture. How do I go about giving the points to you? Is there some way that I can accept this as an answer rather than as a comment?
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2576581
There should be a button on the green 'Comment' line right above his comment (or something like that)

Please make sure you accept his comment as an answer, not mine! ;-)
0
 
LVL 22

Expert Comment

by:ture
ID: 2576615
panikos,
Thank you for the points. I'm glad that I could help you.

p_biggelaar,
Thanks for your friendly directions to panikos.

/Ture
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question