Solved

VBA - Excel programming question

Posted on 2006-11-13
1
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 250 total points
ID: 17930149
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

734 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