14/06/12

Create an Excel UserForm
Search Contextures Sites

Search

Cubilis Channel Manager Manage all your bookingsites on a single interface, no over-bookings! www.cubilis.com PowerBasic vs VisualBasic Faster. No Run-Times. No Bloat! CGI, Macros, ASM, Reg Expressions Wägezellen, Load Cells, Kraftaufnehmer, Wägetechnik, Weighing Sensors, Weight Indicators
www.powerbasic.com

www.gbuettner.de

Create an Excel UserForm
Convert PDF to Word
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
Set up the the worksheet Create an Excel UserForm Name the Excel UserForm Add a Textbox to the Excel UserForm Add a Label to theExcel UserForm Add remaining textboxes and labels Add buttons to the Excel UserForm Add code to the buttons Test the Excel UserForm Create a button to open the Excel UserForm Finish the workbook

with ABBYY PDF Transformer - PDF conversion and PDF creation tool
pdftransformer.abbyy.com

vLookup for Procurement
Learn how use MS Excel functions, including vLookup in this article!
www.NextLevelPurchasing.com

PDF Writer for VB
Create, display, print, edit, merge Royalty-free distribution. Try now!
www.synactis.com

Download the zipped sample Excel UserForm file See also, Excel UserForm video (video is in 3 parts) and Excel UserForm with Combo Boxes .

To make it easier for users to enter data in a workbook, you can create an Excel UserForm. In this example, a parts inventory is stored on a hidden worksheet. Users enter data by opening the Excel UserForm, filling in the boxes, and clicking a button. To view the steps in a short video, click here (video is in 3 parts).

Set up the worksheet
In this example, a parts inventory is stored on a hidden worksheet. 1. 2. 3. 4. 5. Open a new workbook Double-click on the sheet tab for Sheet1 Type: PartsData Press the Enter key In cells A1:D1, enter the headings for the parts inventory database, as shown at right. 6. Choose File | Save, and save the workbook. In this example, the file has been named PartsLocDB.xls.

A B C D 1 PartID Location Date Qty Store 2 12345 3/3/2004 87 001 3

Create an Excel UserForm
Excel UserForms are created in the Visual Basic Editor. 1. To open the Visual Basic Editor, hold the Alt key, and press the F11 key 2. Choose View | Project Explorer, to see a list of projects. (Usually, this is displayed at the left side of the VBE window.) 3. In the Project Explorer, select the PartLocDB project.
contextures.com/xlUserForm01.html 1/5

Type: frmPartLoc and press the Enter key 4. Type: Parts Inventory and press the Enter key 7. to add a standard sized textbox. 1. and drag to the left. From the menu bar. 3. but the form still shows UserForm1 in its title bar. 5. The form name will change in the Project Explorer. with a label Date contextures. In the Properties window. double-click on the Caption property-. click on the Label button. at the top right of the window. with a label Location a textbox named txtDate. choose Insert | UserForm 5. click on the TextBox button. A blank UserForm appears. double-click on the Name property in the Properties window. To allow users to enter data. you can add textbox controls to the form. 4. Add a Textbox to the Excel UserForm The objects on an Excel UserForm. 6. In the Toolbox. To open the Properties window. To view the steps in a short video. Ads by Google Excel Dashboards Download Excel Excel Excel VBA Worksheet Add a Label to the Excel UserForm To help users enter data.14/06/12 Create an Excel UserForm 4.html 2/5 . are called controls. With the new label selected. with label controls to describe them. On the UserForm. press the F4 key 2. Click on an empty part of the UserForm. Type: txtPart and press the Enter key 5. double-click on the Caption property in the Properties window. 1. In the Toolbox. you can resize the label. 3. and textboxes. The title bar will display the new caption. or to display instructions. 6. such as buttons. click to the left of the textbox.com/xlUserForm01.UserForm1. Add remaining textboxes and labels Repeat the above steps to add: a textbox named txtLoc. you can add label controls to describe the textboxes. 4. to add a standard sized label. Type: Part and press the Enter key 5. If necessary. 3. click near the top centre. click here (video is in 3 parts). and the ToolBox should open. 2. On the UserForm. In the Properties window. (If the ToolBox doesn't appear. to select the UserForm and to display the Toolbox. With the new textbox selected. to select the UserForm and to display the Toolbox. so it doesn't cover the textbox -. Click on an empty part of the UserForm. double-click on the Name -UserForm1. choose View | Toolbox) Name the Excel UserForm 1.point to the handle on its right border. 2.

and click on the remaining textboxes Choose Format | Align | Lefts Click on an empty part of the UserForm.el(Rw 2. click at the bottom left.au " M.au =M.el. double-click on the Caption property in the Properties window. with a label Close 9.el(Rw 1. choose View | Code. 8.au =M. erhre:xRw. With the new CommandButton selected. where you can add your code.xDt. 3.xLcVle sClsio. to select the UserForm and to display the Toolbox. On the UserForm. with a label Quantity If the textboxes are not aligned. 1.xPr.xDt.au =M. Type: cmdAdd and press the Enter key 5.o 'hc frapr nme cek o at ubr I Ti(ettatVle =" Te f rmM. Add code to the buttons To make the Excel UserForm buttons perform an action.xPr.el(Rw 4. okn=laus. Type: Add this part and press the Enter key 7. Select the cmdAdd button On the Menu bar.html 3/5 .xLcVle=" etto. Add code to the cmdAdd button 1. you can reposition the buttons by dragging them to a new location on the UserForm. Click on the first textbox Hold the Ctrl key. and a button to close the form. 6. With the new CommandButton selected. This form has a button to add data to the database.xPr. Where the cursor is flashing. double-click on the Name property in the Properties window. )Vle ettatVle w. 2. )Vle ettaeVle w. 4.eFcs ettatStou Mgo "laeetrapr nme" sBx Pes ne at ubr Ei Sb xt u EdI n f 'oytedt t tedtbs cp h aa o h aaae w.au w. SacDrcin=lrvos LoI:xVle)Rw+1 erhieto:xPeiu. you can align them: 1.au =" ettaeVle " contextures.14/06/12 Create an Excel UserForm a textbox named txtQty. you can add command buttons to the user form.au 'la tedt cer h aa M.xQyVle sClsio. to select the UserForm and to display the Toolbox.au sClsio. This creates a procedure.xPr. Add Buttons to the Excel UserForm To allow users to perform an action. Click on an empty part of the Excel UserForm. If required.idWa:"" SacOdr=los _ Rw sClsFn(ht=*.au) " hn M. 2. )Vle ettt.au =" ettatVle " M. 3. )Vle etto.com/xlUserForm01. click on the CommandButton button.au sClsio.el(Rw 3. you create code that runs when the button is clicked. Repeat the above steps to add a CommandButton named cmdClose. enter the following code: PiaeSbcdd_lc( rvt u mAdCik) Dmio A Ln i Rw s og Dmw A Wrset i s s okhe Stw =Wrset(Prsaa) e s okhes"atDt" 'idfrtepyrwi dtbs fn is mt o n aaae io =w. 3. to add a standard sized CommandButton. 4. click here (video is in 3 parts). To view the steps in a short video. In the Toolbox. 4. 2.au =M.

3.Show False contextures. you can change it 1. Add code to the cmdClose button 1. choose View | Object. To allow users to close the form by pressing the Esc key: 1. draw a rectangle. 7. Right-click on an empty part of the UserForm 2. choose View | Code. type: frmPartLoc.xls workbook Double-click on the sheet tab for Sheet2 Type: Parts Data Entry Press the Enter key On the Drawing toolbar.Show Note: If you are using Excel 2000. Select the cmdClose button 2. to return to the UserForm. Click the 'Close form' button. click on the Rectangle tool In the centre of the worksheet. Choose Tab Order 3. Select a control in the list. 3.eFcs ettatStou EdSb n u Create an Excel UserForm 5. Click the New button 10. change the Cancel property to True Ads by Google Excel Excel 2003 Excel VBA Excel to Text Test the Excel UserForm To test the form. 6. and choose 'Assign Macro' 9. In the Properties window. click the 'Add this part' button. On the Menu bar. 5. and want users to be able to do other things while the form is open. Press the tab key to move to the next textbox.html 4/5 1. 3. you can run it from the VBE. and format as desired. Select the cmdClose button 2. type: 12345 4. change the above line to: frmPartLoc. to select the UserForm and to display the Toolbox. and activate the PartLocDB. 2. type: Click here to add Part Information 8. On the Menu bar. With the rectangle selected. choose Run | Run Sub/UserForm. when you pressed the tab key you moved to the wrong textbox or button). 4. to return to the VBE. 4. and click the Move Up or Move Down button 4.g. 1.14/06/12 M. or later version. In the Part textbox. you can add a button to a worksheet.au " M. Switch to Excel.xPr. If the tab order was incorrect (e. Where the cursor is flashing. Click OK Create a Button to open the Excel UserForm To make it easy for users to open the UserForm. . to return to the UserForm. choose View | Object. On the Menu bar. Right-click on the rectangle border.xQyVle=" ettt. 6. Click on an empty part of the UserForm. When the textboxes have been filled in. 2. enter the following code: PiaeSbcdls_lc( rvt u mCoeCik) Ula M nod e EdSb n u View the steps in a short Excel UserForm video (video is in 3 parts).com/xlUserForm01. Where the cursor is flashing. 5. On the Menu bar.

and activate the PartLocDB.com/xlUserForm01. to return to the UserForm. Delete all other sheets. Excel UserForm video (video is in 3 parts) and Excel UserForm with Combo Boxes . CoeoeA Itgr lsMd s nee) I Coeoe=vFrCnrleuTe f lsMd bomotoMn hn Cne =Tu acl re Mgo "laeuetebto! sBx Pes s h utn" EdI n f EdSb n u 4. On the Menu bar. Home Excel Tips Excel Files The Excel Store Blog Contact Privacy Policy Contextures Inc. From the menu bar. 2012 9:09 PM contextures. Select the PartsData sheet. and enter your data into the database. and enter the following code: PiaeSbUeFr_urCoeCne A Itgr _ rvt u sromQeyls(acl s nee. except Parts Data Entry 5. choose Format | Sheet | Hide 4. choose View | Object. Finish the Workbook To finish the workbook. Close and save the workbook Download the sample Excel UserForm file Download the sample file with an enhanced Excel UserForm. Debra Dalgleish Last updated: January 11.14/06/12 Create an Excel UserForm To prevent users from closing the form by clicking the X button: 1. Copyright ©2012 All rights reserved.. with comboboxes See also. you can hide the sheet that contains the database.html 5/5 .xls workbook 2. Scroll to the bottom of the existing code. Switch to Excel. 3. Click the Click here to add Part Information button. Choose View | Code 3. Right-click on an empty part of the UserForm 2. 6. 1.

Sign up to vote on this title
UsefulNot useful