question

AtherMian-4921 avatar image
0 Votes"
AtherMian-4921 asked JackJJun-MSFT edited

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

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

office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AtherMian-4921 avatar image
0 Votes"
AtherMian-4921 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.