473,385 Members | 1,867 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.

Include the spreadsheet name as the first field when importing multiple spreadsheets

2
I have seen the answer for importing multiple spreadsheets though I haven't tried it. How do I include the spreadsheet filename as the first field for all rows. By the way how does this handle if the workbooks are sometimes formated as one worksheet and sometimes two worksheets. The format is generally very similar.
Expand|Select|Wrap|Line Numbers
  1. Function Impo_allExcel()
  2.  
  3. Dim myfile
  4. Dim mypath
  5. mypath = "n:\importxls\aramiska\"
  6. Do
  7. myfile = Dir(mypath & "*.xls")
  8. 'this will import ALL the excel files (one at a time, but automatically) in this folder. Make sure that's what you want.
  9. DoCmd.TransferSpreadsheet acImport, 8, "aramiskaimport2", mypath & myfile
  10. myfile = Dir
  11. Loop Until myfile = ""
  12.  
  13. End Function  
  14.  
After this task I going to work on merging the data many records when some have a common name (field) which I want as one record perhaps in a separate table with the unique data all together- there is a lot of duplicate data.

Thanks in advance
Jan 22 '10 #1
3 1640
nico5038
3,080 Expert 2GB
You have two options:
1) Import all in the same table and have the additional filename column defined.
Afeter the import perform an UPDATE of all rows where the filename column is empty with the filename.
2) Make for every file a different table with the filename and merge them e.g., using a UNION with the filename as additional column.

Nic;o)
Jan 23 '10 #2
cloa
2
Thanks for your reply but could you indicate in either solution how I can automatically gather the spreadsheet name into the database so I can say that this information that I am checking comes from that spreadsheet (they want to keep the spreadsheets). Most spreadsheets are unchangeable data with new updates put on the January spreadsheet so linking is not necessary.





Telling the whole story. There is a html database at work which I suspect is SQL but it is so badly conceived that the information I am checking is not unable to derived from it so they use a spreadsheet system instead (for this data). That is has about 36 files with the last 7 having the same type and format of data as the previous 29+ files but its spread over two worksheets with slightly different header row (one name different) on the second sheet.
Jan 23 '10 #3
nico5038
3,080 Expert 2GB
You're collecting the files using the name with "mypath & myfile", these can be "stringed" into e.g,. an UPDATE query.

Another option might be to link to the sheets to tables instead of importing them and refresh the links. Thus the table names can be "stable" and you can build your needed (UNION and/or APPEND) queries on these.

Nic;o)
Jan 23 '10 #4

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

Similar topics

1
by: Jim, N2VX | last post by:
I'd like to create/display an Excel spreadsheet from javascript. We have an HTML page with results of a search and it can be reasonably large. The first attempt was to format the data into an...
4
by: Howard | last post by:
I am trying to use DoCmd.TranferSpreadsheet to import a spreadsheet into an Access table that's not the CurrentDB. I have the database open, but I don't see how to tell the TransferSpreadsheet...
4
by: Danny | last post by:
When I import the spreadsheet, i get a lot of import errors because it seems that access bases the import field type on the first row. So if a field has a number in first row , then access...
1
by: AMD 3400 | last post by:
I have five spread sheets from 1 to 2500 (rows), and i would like to know how can i pull the remaining four spread sheet onto spread sheet # 1. it work with Cut and Paste, but that's too long, i...
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...
6
by: Duncan Smith | last post by:
Hello, I am currently implementing (mainly in Python) 'models' that come to me as Excel spreadsheets, with little additional information. I am expected to use these models in a web application. ...
2
by: Restless Native | last post by:
I am importing several Excel spreadsheets, and need to use the range in order to capture the field names. If the spreadsheets are closed, I get the following error "The table contains cells that are...
2
by: =?Utf-8?B?RGF2ZSBIdXRjaGluZ3M=?= | last post by:
Hi, I am importing various xl spreadsheets (using ADO and oledbconnection). These spreadsheets are from many countries and therefore some of the details contain foreign characters like the "ó"...
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
7
by: franc sutherland | last post by:
Hi everyone, I am using Access 2003. I have a database with a table in it which is linked to an excel spreadsheet. When I install the database on someone else's system, the pathname to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.