godders199
New member
- Local time
- Today, 13:24
- Joined
- Oct 25, 2017
- Messages
- 1
Hi, I am new to access, I have tried to follow instructions to set up a import VBA from excell, which does work, however for each line it imports , it creates a blank row at the bottom, for example 4 rows of data, will create 4 blank rows.
This is all the VBA i have written, copied guess somewhere it is going wrong.
Private Sub btnbrowse_Click()
Dim diag As Office.FileDialog
Dim item As Variant
Set diag = Application.FileDialog(msoFileDialogFilePicker)
diag.AllowMultiSelect = False
diag.Title = "please select an excel spreadsheet"
diag.Filters.Clear
diag.Filters.Add "excel spreadsheets", "*.xls,*.xlsx,*xlsm"
If diag.Show Then
For Each item In diag.SelectedItems
Me.Textfilename = item
Next
End If
End Sub
Private Sub importspreadsheet_Click()
Dim fso As New FileSystemObject
If fso.FileExists(Me.Textfilename) Then
Excelimport.importexcelspreadsheet Me.Textfilename, "allocation history"
End If
Public Sub importexcelspreadsheet()
Dim strexcelpath As String
strexcelpath = "S:\4th Floor\SQ Operations\OPs Mi Spreadsheets\Allocation audit tools\2018\history.xlsx"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "Allocation history", strexcelpath, True, ""
Is anyone able to help me as currently all i know what to do is manually delete the rows after import which is not a long term solution.
This is all the VBA i have written, copied guess somewhere it is going wrong.
Private Sub btnbrowse_Click()
Dim diag As Office.FileDialog
Dim item As Variant
Set diag = Application.FileDialog(msoFileDialogFilePicker)
diag.AllowMultiSelect = False
diag.Title = "please select an excel spreadsheet"
diag.Filters.Clear
diag.Filters.Add "excel spreadsheets", "*.xls,*.xlsx,*xlsm"
If diag.Show Then
For Each item In diag.SelectedItems
Me.Textfilename = item
Next
End If
End Sub
Private Sub importspreadsheet_Click()
Dim fso As New FileSystemObject
If fso.FileExists(Me.Textfilename) Then
Excelimport.importexcelspreadsheet Me.Textfilename, "allocation history"
End If
Public Sub importexcelspreadsheet()
Dim strexcelpath As String
strexcelpath = "S:\4th Floor\SQ Operations\OPs Mi Spreadsheets\Allocation audit tools\2018\history.xlsx"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "Allocation history", strexcelpath, True, ""
Is anyone able to help me as currently all i know what to do is manually delete the rows after import which is not a long term solution.