Hi,
I need to import data from a specific Excel worksheet (RCO Survey) into an existing table (RCO Data) but I want the user to be able to define the range of the worksheet that is imported. The also determine where the spreadsheet is (e.g. which directory on their own PC)
I am not too good with VBA so I have tried to do the import with the code below but it does not import any data.
Any guidance or suggestions is appreciated.
Private Sub Command41_Click()
On Error GoTo Err_Command41_Click
'This section request the filename and the ranges in the spreadsheet tabs to be imported
Title = "Import Data"
Continue = MsgBox("You will need to know the Excel range that you want to import for the RCO Data before you proceed, You can CANCEL the import at the next step", , [Title])
If Continue = "" Then
GoTo Err_Command41_Click
End If
pathname = InputBox("Enter the full path and file name of the Site Survey Excel File, Data will be imported from the RCO Survey tab (Don't forget the .xls extension!)", [Title])
If pathname = "" Then
GoTo Err_Command41_Click
End If
RCSurveyData = InputBox("Enter the Excel Range for the RCO Survey TAB to be imported, e.g. this should be in the format A4:AE450", [Title])
If RCSurveyData = "" Then
GoTo Err_Command41_Click
End If
'Imports Main Data
DoCmd.TransferSpreadsheet acImport, 8, "RCO Data", pathname, False, "RCO Survey!" & RCSurveyData
Exit_Command41_Click:
Exit Sub
Err_Command41_Click:
MsgBox "Data has NOT been Imported" 'Err.Description
Exit Sub
End Sub
I need to import data from a specific Excel worksheet (RCO Survey) into an existing table (RCO Data) but I want the user to be able to define the range of the worksheet that is imported. The also determine where the spreadsheet is (e.g. which directory on their own PC)
I am not too good with VBA so I have tried to do the import with the code below but it does not import any data.
Any guidance or suggestions is appreciated.

Private Sub Command41_Click()
On Error GoTo Err_Command41_Click
'This section request the filename and the ranges in the spreadsheet tabs to be imported
Title = "Import Data"
Continue = MsgBox("You will need to know the Excel range that you want to import for the RCO Data before you proceed, You can CANCEL the import at the next step", , [Title])
If Continue = "" Then
GoTo Err_Command41_Click
End If
pathname = InputBox("Enter the full path and file name of the Site Survey Excel File, Data will be imported from the RCO Survey tab (Don't forget the .xls extension!)", [Title])
If pathname = "" Then
GoTo Err_Command41_Click
End If
RCSurveyData = InputBox("Enter the Excel Range for the RCO Survey TAB to be imported, e.g. this should be in the format A4:AE450", [Title])
If RCSurveyData = "" Then
GoTo Err_Command41_Click
End If
'Imports Main Data
DoCmd.TransferSpreadsheet acImport, 8, "RCO Data", pathname, False, "RCO Survey!" & RCSurveyData
Exit_Command41_Click:
Exit Sub
Err_Command41_Click:
MsgBox "Data has NOT been Imported" 'Err.Description
Exit Sub
End Sub