Macro to launch data form when table doesn't start at A1

Ather Mian 1 Reputation point
2021-10-15T13:50:59.873+00:00

Hi,

My data is formatted as an Excel table and the table starts at A5. All I am trying to do is show the built-in Excel form

When I run the following macro I get this error.

Run-time error 1004 ShowDataForm Method of Worksheet class failed

Sub DataForm()
ActiveSheet.ShowDataForm
End Sub

Your help is greatly appreciated.

Thanks,

Ather

Office Visual Basic for Applications
Office Visual Basic for Applications
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Visual Basic for Applications: An implementation of Visual Basic that is built into Microsoft products.
1,503 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 121.6K Reputation points
    2021-10-15T16:26:29.497+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

Your answer

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