Removing rows in an import

auror1968

New member
Local time
Today, 00:11
Joined
Sep 19, 2013
Messages
2
HI

I have an excel sheet that I want to import, it has 3 rows at the top which are titles that I don't want. Can I miss these rows out using the standard import function or do I need to write a custom VBscript ?

If I need to write a VBscript, is there any good examples around ?

Many thanks

Nigel
 
Hello,

With TransferSpreadsheet method, you can define the range of cells that you need to import.

Good continuation.
 
Ok, thanks for that but I will be wanting to repeat the import each month and the number of rows may vary, is it possible to set a range that is miss out the top 3 lines but all other rows ?
 
Hello,
Were y
ou trying something or did you search with F1?
Because the 6th argument allow you to define the range of cells that you need. And you can use a variable.
For exemple, the code below imports the range of cells A1:B20 from the example.xls file in the folder of the project as a table named TableImport. You can introduce a code to have a dynamic value of RangeCell.
Code:
Public sub .....
...
RangeCell = "A1:B20"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel5, "TableImport" & Format(Now, "mm"), CurrentProject.Path & "/example.xls", , rangecell
...
End Sub
Good continuation
 

Users who are viewing this thread

Back
Top Bottom