excel vba shoDataForm Run-time error '1004'

2019-08-14 04:58发布

 ActiveSheet.ShowDataForm

Returns Error 1004

I tried

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

It didn't Help

1条回答
放我归山
2楼-- · 2019-08-14 05:08

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

查看更多
登录 后发表回答