473,385 Members | 1,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

import data from other xls spreadsheets into one spreadsheet

Hello, how do i import data from cells of specific work sheets of other xls spreadsheets into one spreadsheet? Thanks in advance.
Jan 17 '10 #1
1 2389
yarbrough40
320 100+
put all the files containing the data to be merged into the same folder.
in that same folder create a seperate xls file and run this macro:

Enjoy!
Expand|Select|Wrap|Line Numbers
  1. Dim wkb As Workbook
  2.     Dim wks As Worksheet
  3.     Dim rngSource As Range
  4.     Dim rngDestination As Range
  5.  
  6.     Dim myDir As String
  7.     Dim fn As String
  8.  
  9.     myDir = ThisWorkbook.Path & "\"
  10.  
  11.     fn = Dir(myDir & "*.xls")
  12.  
  13.     Do While fn <> ""
  14.  
  15.         If fn <> ThisWorkbook.Name Then
  16.             Set wkb = Workbooks.Open(myDir & fn)
  17.             With wkb
  18.                 Set wks = .Sheets(1)
  19.                 Set rngSource = wks.Range("A1:V400")
  20.                 Set rngDestination = ThisWorkbook.Sheets(1).Range("a" & Rows.Count).End(xlUp)(2) _
  21.                     .Resize(rngSource.Rows.Count, rngSource.Columns.Count)
  22.                 rngSource.Copy Destination:=rngDestination
  23.  
  24.                 .Close False
  25.  
  26.             End With
  27.         End If
  28.  
  29.         fn = Dir
  30.     Loop
  31.  
  32.     Set rngSource = Nothing
  33.     Set rngDestination = Nothing
  34.     Set wks = Nothing
  35.     Set wkb = Nothing
  36.  
  37.  
Jan 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Steve Jorgensen | last post by:
I'm restarting this thread with a different focus. The project I'm working on now id coming along and will be made to work, and it's too late to start over with a new strategy. Still, I'm not...
3
by: deko | last post by:
I've been trying to use the Access Import Wizard to expedite importing data into my mdb. The nice thing about the wizard is that I can import from different file formats - txt, xls, even Outlook -...
5
by: Java script Dude | last post by:
For those who are missing the feature on how to import into Open Office dBase app from text files and spreadsheets in OOO Base 2.0: A wizard exists to import from spreadsheets only at this time...
2
by: google | last post by:
Is there anyway to programatically confirm that specific field names exist in the first row of a given Excel spreadsheet from code within Access? I have code set up to import data from our...
3
by: Kbalz | last post by:
Hello, I'm trying to create an application for a friend's business. He gets Excel Spreadsheets from a lab - he would like for his partners to be able to Upload this Sheet to a website, and have the...
9
by: cabrenner | last post by:
I am new to SQL Server, and migrating part of an Access application to SSE. I am trying to insert a comma delimited file into SSE 2005. I am able to run a BULK INSERT statement on a simple file,...
0
by: mix01 | last post by:
Hi, I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help. Many thanks, Mix01 Version of the program
0
by: nuray | last post by:
I have a spreadsheet where I run a query in Access and copy it into the specific spreadsheets. I was trying to use Data->import external data->import data tool in excel to get the data automaticly...
4
by: David | last post by:
Hi I'm using this code to import data from an excel spreadsheet: DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "tblStudents", _ "\\Egusersrv\Staff - Shared Work\PE Teach &...
2
by: BlackEyedPea | last post by:
Hi I have no coding experience but am using access 2003 on XP in the hope that I can find some code that will.... Search a folder in my network & import any excel spreadsheets it finds within...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.