robertsquestion
Technical User
Hi,
I'm using MS Office 2003 and have got a question about importing an Excel file with VBA into an MS Access table.
The Excel file needs to be imported once a week. It's exported from another system to a default folder and the Excel file always gets the same name (let 's say 'data.xls'). Row 1 contains the following values (fieldnames):
A1 = customernr.
B1 = materialnr
C1 = sales
D1 = districtnr.
The rows starting from row 2 contain the actual data.
Now my Access table ('T_data') contains the following fields:
customernr
materialnr
sales
districtnr
So that's exactly the same as row 1 of the excel file, except for A1 and D1 because this fieldname contains a dot in the excel file.
Now I would like to import the excel file using 'TransferSpreadsheet'. Is there a way to adjust the excel cells A1 and D1 with (MS Access)VBA before importing the excel file? So the preferred steps would be:
1. check if cell value A1 = customernr. => if so, replace cell value A1 = customernr
2. check if cell value D1 = districtnr. => if so, replace cell value D1 = districtnr
3. import the adjusted file in table 'T_data'
I know that if you manually import the file ('Get external data') Access automatically removes the dots. But the goal is to import the file with VBA.
I hope someone out there can help me out!
Thanks,
Robert
The Netherlands
I'm using MS Office 2003 and have got a question about importing an Excel file with VBA into an MS Access table.
The Excel file needs to be imported once a week. It's exported from another system to a default folder and the Excel file always gets the same name (let 's say 'data.xls'). Row 1 contains the following values (fieldnames):
A1 = customernr.
B1 = materialnr
C1 = sales
D1 = districtnr.
The rows starting from row 2 contain the actual data.
Now my Access table ('T_data') contains the following fields:
customernr
materialnr
sales
districtnr
So that's exactly the same as row 1 of the excel file, except for A1 and D1 because this fieldname contains a dot in the excel file.
Now I would like to import the excel file using 'TransferSpreadsheet'. Is there a way to adjust the excel cells A1 and D1 with (MS Access)VBA before importing the excel file? So the preferred steps would be:
1. check if cell value A1 = customernr. => if so, replace cell value A1 = customernr
2. check if cell value D1 = districtnr. => if so, replace cell value D1 = districtnr
3. import the adjusted file in table 'T_data'
I know that if you manually import the file ('Get external data') Access automatically removes the dots. But the goal is to import the file with VBA.
I hope someone out there can help me out!
Thanks,
Robert
The Netherlands