Solved

VBA - Excel programming question

Posted on 2006-11-13
1
135 Views
Last Modified: 2010-04-30
Hello,
 
I'm maintaining a project that I didn't originally code.  This code lies in an MSAccess import program that imports data from an Excel spreadsheet.

The spreadsheet was originally laid out without using Named Ranges, but this code appears to do something similar to a named range. Ths spreadsheet has column headers in Row 1 and data starting in Row 2.  The Row 1 value for this column M is "Imperial_Or_Metric".

I can't figure out how the following line knows to gather data and where from??  The real issue is I added named ranges for my additions and I added some data definition info in rows 2-4 and now have import data rows starting in row 5 and my MSAccess import program now dies on this line:


DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Imp_UofM", Me.txtPath, True, "Unit_Of_Measure!A1:B65000"


Can someone interpret this line of code and how I can make it get along with NameRanges or at minimal make it start at row 5 of my spreadsheet for actual import data?

Thank You,
JMO9966
0
Comment
Question by:JMO9966
1 Comment
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 250 total points
Comment Utility
It is hard coded in the "Unit_Of_Measure!A1:B65000", but it is using the field names from the spreadsheet, (the "true")

If you could move the fieldnames into row 5 instead of row 1, you could simply change "Unit_Of_Measure!A1:B65000" to "Unit_Of_Measure!A5:B65000", however, if you need to keep the field names in row 1, you could change it AND change the "True" to "false", but your resulting table would not get the field names.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

11 Experts available now in Live!

Get 1:1 Help Now