?
Solved

Moving data across files

Posted on 2000-03-02
4
Medium Priority
?
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
ture earned 400 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 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