Auto open Data-Form option

  • Thread starter Marjo van den Nieuwenhuijzen
  • Start date
M

Marjo van den Nieuwenhuijzen

Hi all,

What I want to do probably requires some VBA code. Since I am not very good
at that:
I have a workbook with lots of data organised in columns. What I want to
achieve is that when I open the workbook it automatically opens the
Data-Form option.

Thanks in advance for your replies.

Marjo van den Nieuwenhuijzen
 
P

papou

Hi Marjo
Right-click on the Excel icon situated immediately on the left of the File
menu in Excel, choose View code and paste the following code sample:
Private Sub Workbook_Open()
Application.DisplayAlerts = False
ActiveSheet.ShowDataForm
Application.DisplayAlerts = True
End Sub

Please note that in the above sample code there is no control as regards the
activesheet beeing the sheet with data so you may want to test whether the
active sheet is the sheet containing your data, in which case you may change
with:
WorkSheets("YourSheet").ShowDataForm

HTH
Cordially
Pascal
 
M

Max

Give this a try ..

Assuming the dataform is to open in Sheet1
and you have in cols A and B, the list:

Lname Fname
Smith John
etc

Notes:

a. Format row1* (i.e. the col headers/labels) say, in bold
to enable Excel to recognize the col labels easily

*From help: Use a font, alignment, format, pattern,
border, or capitalization style for column labels that is
different from the format you assign to the data in the
list.

b. Ensure there is at least one row of data in the list to
start with (again this is to ease Excel in differentiating
data rows from col labels)

Try the sub below
(which goes into the "ThisWorkbook" module)

Right-click on the Excel icon just to the left of "File"
Choose "View Code"
This will bring you direct into the "ThisWorkbook" module

Copy and paste the sub below (everything within the dotted
lines) into the whitespace on the right
(clear the defaults appearing in the whitespace first)

----------begin vba------
Private Sub Workbook_Open()
With Sheets("Sheet1")
ActiveSheet.ShowDataForm
End With
End Sub
----------end vba----------

Press Alt+Q to get back to Excel

Save and close the workbook

Test by re-opening the workbook
 
Top