Solved

Moving data across files

Posted on 2000-03-02
4
136 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now