PC Review


Reply
Thread Tools Rate Thread

DoCmd.Transferspreadsheet - need help in determining Excel range

 
 
DanRoy
Guest
Posts: n/a
 
      14th Aug 2008
Hello,

I developed a usable transferspreadsheet command in my code, but since the
data starts on row 3, I cannot use the default for range. My tables have
field 1 as a key field and any blank records, such as blank lines, cause an
error.

(CPSPass is the tab in the excel workbook I am reading)

Here is the code I am using:

tablename = "Dash-Import"
fn = "G:\Proposals\ECP0419 Program Affordability\BOEs\BOE Scorecard\BOE
Database\ECP419-1CPSPass1c as of 7-30-08.xls"


DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel3, tablename, fn,
True, "CPSPass!A2:z200"


In this particular table, I have the field titles in row 2, and data in rows
3-149. In the 7 other files that I will be importing, I may have as many as
1500 rows of data. I am trying to develop a routine I can use without regard
for the number of rows in any particular file. All of the files I will
import will have the same exact file structure.

To set the range correctl for a particular file I am reading, I need to know
the last row of data in the excel file to replace the "Z200" reference above.

Do you have any suggestions? Would you suggest that prior to performing the
excel import using the transferspreadsheet protocol, I should open an
instance of Excel, open the file, save the maxrows to Access as the upper
range for my import?

Thanks

Dan

 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      14th Aug 2008
On Thu, 14 Aug 2008 11:07:06 -0700, DanRoy wrote:

> Hello,
>
> I developed a usable transferspreadsheet command in my code, but since the
> data starts on row 3, I cannot use the default for range. My tables have
> field 1 as a key field and any blank records, such as blank lines, cause an
> error.
>
> (CPSPass is the tab in the excel workbook I am reading)
>
> Here is the code I am using:
>
> tablename = "Dash-Import"
> fn = "G:\Proposals\ECP0419 Program Affordability\BOEs\BOE Scorecard\BOE
> Database\ECP419-1CPSPass1c as of 7-30-08.xls"
>
> DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel3, tablename, fn,
> True, "CPSPass!A2:z200"
>
> In this particular table, I have the field titles in row 2, and data in rows
> 3-149. In the 7 other files that I will be importing, I may have as many as
> 1500 rows of data. I am trying to develop a routine I can use without regard
> for the number of rows in any particular file. All of the files I will
> import will have the same exact file structure.
>
> To set the range correctl for a particular file I am reading, I need to know
> the last row of data in the excel file to replace the "Z200" reference above.
>
> Do you have any suggestions? Would you suggest that prior to performing the
> excel import using the transferspreadsheet protocol, I should open an
> instance of Excel, open the file, save the maxrows to Access as the upper
> range for my import?
>
> Thanks
>
> Dan


I believe :z will return all records to the end of column Z.

"CPSPass!A2:z"
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
More the one range with DoCmd.TransferSpreadsheet amir369 Microsoft Access External Data 1 14th Jan 2009 03:11 AM
more the one range with DoCmd.TransferSpreadsheet amir369 Microsoft Access External Data 0 13th Jan 2009 07:14 AM
DoCmd.TransferSpreadsheet and referencing an Excel range pmartin1960@hotmail.com Microsoft Access 1 27th Apr 2006 04:19 AM
Importing from Excel using DoCmd.TransferSpreadsheet David Cleave Microsoft Access External Data 2 16th Jul 2004 04:34 PM
Importing Excel using DoCmd.TransferSpreadsheet Grace Microsoft Access External Data 2 2nd Mar 2004 06:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:54 PM.