• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Macro to import data from excel to access

Hello everyone,

I have reports that come in on daily basis in form of Excel spreadsheet. I would like to set up a program or macro that would take values from these spreadsheet and store in access database. Additional information is the spreadsheet names will remain the same all the time and there is only one table to be updated..I can sit and write a macro but before that I felt that this is such a common task someone might have already done this..if yes please share..

Thank you.
0
Aiysha
Asked:
Aiysha
  • 5
  • 4
  • 2
  • +1
1 Solution
 
wasiftoorCommented:
You probably will not have to write a macro for this task. You can simply import the data any time from the Excel Spreadsheet and Access will automatically append the new data to the existing data for you utilizing an easy to use Wizard. Screenshot attached. Good Luck.

Import Excel Data In Access Database
0
 
AiyshaAuthor Commented:
Will this macro allow me to get data from specific "fixed" cell in excel into new row in access table?
0
 
Rey Obrero (Capricorn1)Commented:
you can use this command line

for Office2007 or office2010
docmd.transferspreadsheet acimport,10,"TableName","c:\folderName\myExcel.xlsx",True,"NameOfSheet!"


for Office2003
docmd.transferspreadsheet acimport,8,"TableName","c:\folderName\myExcel.xls",True,"NameOfSheet!"


you can call the codes in the clikc event of a button in a form or from a macro..
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
Jeffrey CoachmanMIS LiasonCommented:
<Additional information is the spreadsheet names will remain the same all the time>
?
So what will be different for each file?
Please be specific or post two clear spreadsheet examples...

<there is only one table to be updated.>
Then you will may have to first import the data (with code similar to what capricorn1 posted)
Then run an "Append" query to add the new data to the existing table...

For example
Table1 is the existing Access table
Table2 is the imported Excel file
The query would look like this:

INSERT INTO Table1 ( SomeName, SomeNumber )
SELECT Table2.SomeName, Table2.SomeNumber
FROM Table2;

But again, you need to provide an example of a few of these "sequential" spreadsheets


This all being said, this becomes more complex because we don't know if the Excel file will always be the same or will be different for each import.
So you may need code to rename the files...

Again, we need more info and sample files...
0
 
Rey Obrero (Capricorn1)Commented:
i don't see the need for an APPEND query...
0
 
Jeffrey CoachmanMIS LiasonCommented:
Perhaps not, but the OP did post:
"there is only one table to be updated"
0
 
Rey Obrero (Capricorn1)Commented:
"there is only one table to be updated",  so  where is the need for the APPEND query?
0
 
AiyshaAuthor Commented:
its updated on daily basis.
0
 
Rey Obrero (Capricorn1)Commented:
What version of Office are you using?
0
 
Jeffrey CoachmanMIS LiasonCommented:
capricorn1,
<where is the need for the APPEND query?>
As I said, I am not sure...
...to me, the term "Updated" and the statement:
<I have reports that come in on daily basis in>
...say that perhaps an append "Might" be needed...

In any event, the OP has just posted...
..perhaps you can ask them what is really needed here...?

Jeff
0
 
Rey Obrero (Capricorn1)Commented:
@jeff, see how the docmd.transferspreadsheet works..
0
 
Jeffrey CoachmanMIS LiasonCommented:
No need, I have moved on

I'm sure you can handle this...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now