Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8474737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:42:14+00:00 2026-06-10T17:42:14+00:00

I have created an excel worksheet in a such way that the user can

  • 0

I have created an excel worksheet in a such way that the user can insert some rows (max 100).

The value of some fields are chosen from a dropdown list.

I put the formula on all 100 rows.

The problem is that the data are not imported in access, if the user inserts less of 100 rows. In this case the data are imported only if I delete the formula for the dropdown list from the remaining rows.

To import excel data in access I use:

DoCmd.TransferSpreadsheet [Transfer Type], [Spreadsheet Type], [Table Name], [File Name], [Has Field Names], [Range]

How could I resolve this issue?

EDIT

After the Remou’s answer, I tried with:

Private Sub import_Click()

Dim openDialog As FileDialog
Dim FileChosen As Integer

Set openDialog = Application.FileDialog(msoFileDialogFilePicker)
On Error GoTo DoNothing
With openDialog
  .title = "Import"
  .AllowMultiSelect = False
  .Show
End With

filename = openDialog.SelectedItems.Item(1)

Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim rng As Excel.Range

Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set wb = xl.Workbooks.Open(nomeFile)

c = wb.Worksheets("Sheet1").Range("1:1").end(-4161).Address
r = wb.Worksheets("Sheet1").Range("A:A").end(-4121).Row

ImportRange = "Sheet1!" & "A1:" _
   & Replace(Mid(c, 1, InStrRev(c, "$")) & r, "$", "")

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, _
"ImportTable", filename, True, ImportRange

DoNothing:
    If Err.Number = cdlCANCEL Then
    End If

End Sub

but I’ve a debug error on Dim xl As Excel.Application

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:42:16+00:00Added an answer on June 10, 2026 at 5:42 pm

    NOTE Having tested with Excel dropdowns and validation dropdowns, I find I do not have any problems importing data with validated cells or dropdowns in unused ranges, other than those rows are imported, even though all other cells are empty. The problem may be with data types and importing into an existing table. You may have to import to a scratch table and then append.

    I suggest you use automation to get the used range and add that as the range to import.

    This sample code uses late binding. You can add a reference to the Microsoft Excel x.x Object Library, so I have kept the various definitions, but late binding is best if you are using the code on more than one PC.

    Dim xl As Object ''Excel.Application
    Dim wb As Object ''Excel.Workbook
    Dim rng As Object ''Excel.Range
    
    Set xl = CreateObject("Excel.Application")
    xl.Visible = True
    Set wb = xl.Workbooks.Open("z:\docs\test.xlsx")
    
    'Choosing a column that is fully filled on sheet5
    'xldown=-4121,xltoright=-4161
    c = wb.Worksheets("Sheet5").Range("1:1").end(-4161).Address
    r = wb.Worksheets("Sheet5").Range("A:A").end(-4121).Row
    
    ImportRange = "Sheet5!" & "A1:" _
        & Replace(Mid(c, 1, InStrRev(c, "$")) & r, "$", "")
    
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, _
        "ImportSheet2", "Z:\Docs\csharp.xlsm", True, ImportRange
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel worksheet that has 30k+ rows. I'd like to cut the
I have created a macro for excel which will pop up form that contains
I have the following routine that dumps a DataTable into an Excel worksheet. private
I have created a simple excel worksheet. This is my macro code: Sub MyMacro()
I'm working on some VBA scripts for an Excel worksheet, and I've created a
I have the this code that will create excel file and work sheet then
I have created Excel Sheet using Java program. It works fine. My problem is,
I have created an Excel document using OpenXml SDK 2.0, now I have to
we have created a VSTO Excel workbook with VS2010, .NET 4.0. After we publish
I have created a application in c# , it reads excel file and after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.