AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Creating A Userform In Vba3/13/2021
It also lets we use words that are otherwise reserved (e.g. txtDate instead of Date).With a userform, we can create a user-friendly interface for our workbook or document.Thus, data entry to the worksheet becomes more controllable and easier.
Creating A Userform In Vba How To Create ANow lets see how to create a simple userform to enter personal spending data.Lets start Excel,select a worksheet and open the Visual Basic Editor (to open from keyboard shortcut: press keys).We will need to use both the Project Explorer and the Properties Window, if they are not visible lets open them from the View menu. Tip: When building the userform try to avoid double-clicking on anything(item of userform),because this opens the forms code window. If you accidentally open the code window, close the code window by clicking its Close button,or you can view the UserForm design window pressing the keyboard shortcut. Lets select the current workbook in the Project Explorer and lets open the Insert Menu and choose UserForm.The blank UserForm appears in the code window of the Visual Basic Editor and a corresponding entry appears in the Project Explorer. The Project Explorer shows a new folder named Forms,also Forms folder contains the new UserForm which has been given the name UserForm1. To add a control to userform, we click on the corresponding icon on the Toolbox and drag it onto the userform. On the border, in the lower-right corner and halfway along the bottom and right sides of the form, are small white squares. We can use the mouse to drag these handles to make the UserForm the required size. The grid of dots on the UserForm is for to help that we easily align items placed there. With the UserForm selected,lets find the Name property in the Properties Window (it is normally the first item in the list) and lets change it frmExpenses. When naming UserForm and their controls,we must not include spaces in the name or use any of the VBA reserved words (i.e. The standard selection of controls is represented by buttons on the Toolbox. Lets point at a Toolbox button to see a tooltip showing the name of the control. Lets add a TextBox control to the form by clicking on the TextBox button in the Toolbox then clicking somewhere near the centre of the form. As with the UserForm itself any control that we place on the form shows a dotted border and resizing handles when the item is selected (click on any itemto select it). To move a control drag the dotted border at a point between resizing handles (the mouse pointer will show a four-headed arrow or change the values of its Top and Left properties). This way, we can drag and drop the textbox to any point we want on the form. Lets use the Properties Window to change its name to txtFirstName. It forces the names to appear together when displayed in a list. It also lets we use words that are otherwise reserved (e.g. Date instead of Date).
0 Comments
Read More
Leave a Reply. |