Excel macro to launch default dataform when table doesnt start on A1

Ather Mian 1 Reputation point
2021-10-15T14:40:22.4+00:00

Hi,

Using Excel 2016. I have data formatted as table but which start on A5. When I run this macro I get the following error.

Run-time error 1004 ShowDataForm Method of Worksheet class failed

Sub DataForm()
ActiveSheet.ShowDataForm
End Sub

Any help would be greatly appreciated.

Thanks,

Ather

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 112.1K Reputation points
    2021-10-15T16:26:01.803+00:00

    According to search results (https://www.bing.com/search?q=ShowDataForm+error+1004), try this:

    Sub DataForm()
       ActiveSheet.Range("A5").CurrentRegion.Name = "database"
       ActiveSheet.ShowDataForm
    End Sub
    
    0 comments No comments

  2. Ather Mian 1 Reputation point
    2021-10-15T18:48:27.467+00:00

    Thank you I have tried this. This default table form works only if you have a table. I tried putting my table name in the code above but get an error.

    It all works nicely if your table starts in A1.

    Ather

    0 comments No comments