Creating a Custom Data Form from a Macro in ExcelLast reviewed: November 4, 1994Article ID: Q73387 |
The information in this article applies to:
SUMMARYThe custom data form in Microsoft Excel is limited to two types of dialog items: static text and edit boxes. If you want to include other types of items, such as list boxes or option buttons, you must create a macro to duplicate the function of the data form. This article describes a basic macro that allows you to add records to an existing database using a custom dialog box, which acts as a custom data form. To use this macro, you must have a working knowledge of creating and using dialog boxes and have a worksheet with a defined database on it.
MORE INFORMATIONThe macro is listed below with an explanation of each step following. Warning: Read through this article before attempting to type this macro because the macro will need to be adjusted to fit your individual needs.
Sample MacroA1: Custom_Form A2: =IF(ISERR(GET.NAME("!Database")),ALERT("Database not defined",3)) A3: =IF(ISERR(GET.NAME("!Database")),GOTO(A8)) A4: =DIALOG.BOX(dialog_ref) A5: =IF(A4=FALSE,GOTO(A8)) A6: =FORMULA(initresult,OFFSET(!Database,ROWS(!Database),N,1,1)) . . (similar FORMULA statements) . A7: =DEFINE.NAME("Database",OFFSET(!Database,0,0,ROWS(!Database)+1, COLUMNS(!Database)))A8: =RETURN()
Explanation
Another option for using your custom data form is to modify the Data Form command in Microsoft Excel so that it runs your Custom Data Form macro. To do this, you should create and define the name "Auto_open" on your worksheet so that it refers to a macro similar to the following:
A13: =DELETE.COMMAND(1,"Data","Form...") A14: =ADD.COMMAND(1,"Data",A17:B17,1) A15: =RETURN() A17: Custom_Form B17: R1C1 REFERENCES"Microsoft Excel User's Guide," for Windows and OS/2, version 3.0, pages 348-368, 624-640
|
KBCategory: kbprg kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |