SachAccess
Active member
- Local time
- Today, 17:09
- Joined
- Nov 22, 2021
- Messages
- 391
Hi,
I am trying to import an Excel file in Database using VBA. I have copied code from below URL. Code is working fine.
However have few doubts about this code.
Access - Import Data From Excel Spreadsheet Into Access Database With DoCmd | VBAmacros.net
While importing data, first row after the table field is blank, not able to understand the reason.
Also, data is not imported in the same serial order as it is.
Please note, just trying to learn, please help only if you get time.
I am trying to import an Excel file in Database using VBA. I have copied code from below URL. Code is working fine.
However have few doubts about this code.
Access - Import Data From Excel Spreadsheet Into Access Database With DoCmd | VBAmacros.net
While importing data, first row after the table field is blank, not able to understand the reason.
Also, data is not imported in the same serial order as it is.
Please note, just trying to learn, please help only if you get time.
Code:
'https://vbamacros.net/macros/access-import-data-from-excel-spreadsheet-into-access-database-with-docmd
Option Compare Database
Private Sub Select_File_Click()
' Set variables
Dim strTableName As String
Dim strFileName As String
Dim blnHasHeadings As Boolean
'Set data
strTableName = "tblCustomers"
strFileName = "Y:\MS Access\Dummy_Data.xlsb"
blnHasHeadings = True
' Import data
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, strTableName, strFileName, blnHasHeadings
MsgBox "Excel file imported!", vbInformation
End Sub