Solved

Moving data across files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check Disk (CHKDSK) on all volumes and fix if needed. 8 178
How to create a duplicate finder Application 9 113
Add and format columns in vb6 7 46
Spell Check in VB6 13 95
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

914 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

17 Experts available now in Live!

Get 1:1 Help Now