473,388 Members | 1,390 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,388 software developers and data experts.

How to import an Excel Spreadsheet without specific column(s)?

jbt007
40
Hi All,

I am using the following code to import a spreadsheet into my Access 2003 tblWeekly table:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "tblweekly", strOutFile, True, "impData"
The strOutFile contains the path and file name of the spreadsheet. The "impData" is the range that contains the data I need to import. It is a fluid range (changes from week to week). The spreadsheet is created using Access Automation (reading a txt file report and converts it to a spreadsheet). My user community has requested I add a specific field to the spreadsheet in a specific location, which is not a problem. The issues is that I then import the sheet into a table in the db. This added field will cause the data to break normalization rules as there is already a primary key field linked (one-to-many) to the added field data in the spreadsheet. So, I just want to ignore column "C" in the "impData" range.

I can't find any thread showing how to do this or if it's possible. I have not tested, but if the table field names match the field names in the spreadsheet, will it just be automatically omitted?

The only other thing I can think of would be to do one of the following:
  1. - a. save the workbook, b. delete the column in question, c. import the sheet, and c. close the workbook without saving
  2. - a. create a new sheet in the workbook, b. copy "impData" to the new sheet, c. Delete the column in question, d. name the range of data on the new sheet without the added column to "impDataReal", e. import "impDataReal", f. delete the added sheet.
  3. - build the impData range omitting the column. Something like:
    Expand|Select|Wrap|Line Numbers
    1. With xlSht
    2.     strRng = .Range(xlSht.Cells(1, 1), xlSht.Cells(2, 1058)).Address & "," & .Range(xlSht.Cells(4,  1058)).Address
    3. End With
    Then do the import with "strRng" vs "impData". - not sure how this would work either, because "strRng" would be "$A$1:$B$1058,$C$1:$C$1058" - Does the importsheet support non-continuous ranges?

Methods 1 & 2 above seem kind of "clunky" to me. I was hoping someone out there had a better way! I'll have to try #3, but something tells me Access isn't going to like it.

Thanks in advance...
Jul 14 '10 #1
1 3230
nico5038
3,080 Expert 2GB
In general I would separate the import from the actual data to be processed.
So in a similar situation I've created a tblImport holding all columns and with an ImportSessionNumber to keep the imported files "separated".
Next I fill the actual table using a query selecting the proper columns from the tblImport for the highest ImportSessionNumber.
This has an additional advantage that (depending on the number of sessions you store) you can "go back" when some data wasn't OK or you want to review historical info.

Nic;o)
Jul 14 '10 #2

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

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
7
by: palgrave | last post by:
Hi, How do you create an html link from a web page to a read-only excel spreadsheet without the browser asking if the user wants to open it or save it?
5
by: Colleyville Alan | last post by:
I need to import a spreadsheet into an Access table. The spreadsheet has performance for mutual funds for various periods. The problem is that if there is no info for a particular period, the...
3
by: Ken Hall | last post by:
Is it possible to create an Excel spreadsheet using VB.NET without opening the Excel application or having to have the Excel application on the operating computer? KH
6
by: syvman | last post by:
Hi everyone... I am pulling my hair out trying to do this, and was wondering if someone could give me some assistance... I have an Excel spreadsheet containing several worksheets. I'd like to be...
5
by: Uma Muthu | last post by:
Hi, I have an ASP.NET (2.0) webform. I want to import an excel spreadsheet. In that Excel spreadsheet are specific cells that I want to capture specific data from. Is it doable? Thanks, ...
0
by: ssrirao | last post by:
There is an Excel Spreadsheet containing data, residing in an internet site. It’s very easy to Import data from a local Excel Spreadsheet into SQL Server Database Table using DTS. But in my case...
0
by: Problematic coder | last post by:
Hi, I have just been asked to create an app that will import a specific column from an excel spreadsheet, something like sheet1 columnD or a column with the first row with a value of 'ID'...
1
by: rmmiller44 | last post by:
I have a web page with an HTML dropdown box where users select from among various cities, e.g. Atlanta, New York, Los Angeles, etc. The desired output is a table and charts with data for that city. ...
10
by: Lipper | last post by:
Is there a way to automate a process to import an excel spreadsheet without the first and last couple of rows into Access?
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.