+ 1

use range on transferspreadsheet to import excel to access in vba

Hi i want import Excel to Access by vba but i want get only odd column No even (A,C,E,... column) my code is: DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "t1", fileName, True, "a:a,c:c,e:e" but got error could not find this object(a:a,c:c,e:e) what is solution?

3rd Jul 2020, 2:28 PM
Hadi
Hadi - avatar
3 Answers
+ 1
Have a look at this link. https://social.msdn.microsoft.com/Forums/sqlserver/en-US/6bf0e093-6e3b-460b-b678-6d35bc7ef7c6/docmdtransferspreadsheet-acimport-from-specified-workbook-tab?forum=accessdev It seems that range is define with letters for columns and numbers for rows. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, _ "NYTTKGAUNDERLAG", strFolder3 & "NYTTKGAUNDERLAG" & ".xlsx",_ True, "Grupperat!A1:C1000" I do not think it is possible to get only odd columns. You have to get them all and filter afterwards or do the request three times.
3rd Jul 2020, 2:52 PM
sneeze
sneeze - avatar
+ 1
There is way to save columns on virtual table then get odd column?
3rd Jul 2020, 3:19 PM
Hadi
Hadi - avatar