Share via

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

Developer technologies | Visual Basic for Applications
0 comments No comments

2 answers

Sort by: Most helpful
  1. 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

    Was this answer helpful?

    0 comments No comments

  2. Viorel 127K 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
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.