excel vba shoDataForm Run-time error '1004'

2019-08-14 05:16发布

问题:

 ActiveSheet.ShowDataForm

Returns Error 1004

I tried

Range("B4:D4").Select
ActiveSheet.ShowDataForm

It didn't Help

回答1:

When you use the ShowDataForm method, Microsoft Excel looks for the data list in two places:

  • The defined name "Database." If a range has been defined as the database, Microsoft Excel will display the data form, and the data in that range will be accessible.
  • Cells A1:B2 on the specified worksheet. Microsoft Excel will attempt to find a list whose upper-left corner lies in the range A1:B2. If a list is found, Microsoft Excel will display the data form and the data in the list will be accessible.

WORKAROUND

  1. Either place the Table in A1:B2 Range.
  2. Or Name the Range Database, Ex:

    Range("B5").CurrentRegion.Name = "database"
    ActiveSheet.ShowDataForm
    

    worked for me
    Source 1
    Source 2