Creating a User Form. A Better Interface Our programs can use input boxes for input and write on the spreadsheet page for output This works ok but is.

Slides:



Advertisements
Similar presentations
Sep-05 Slide:1 VBA in Excel Walter Milner. Sep-05 Slide:2 VBA in Excel Introduction VBA = Visual Basic for Applications Enables end-user programming In.
Advertisements

Pivot Tables. What are Pivot Tables? A pivot table gives you a way to group, summarize and compare data from a spreadsheet You can do some of the same.
Mouse Tutorial for Win XP In this tutorial you will learn to: Move the mouse Click and double click Make selections Manage windows Use menus Click the.
Using VB with MS Applications R. Juhl, Delta College.
KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Microsoft Office 2007 Excel Chapter 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Corporate Property Automated Information System (CPAIS) Macro Walkthrough Guide for Excel Version 2003.
How to get started with Excel VBA. We need to enable programming in Excel  the “Developer menu”
Excel and VBA Creating an Excel Application
Using the Visual Basic Editor Visual Basic for Applications 1.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Introduction to Visual Basic Chulantha Kulasekere.
Chapter 12: Recording Macros Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Macros in Excel Intro to lab 1. Macroinstructions Macro is recorded in VBA module sequence of Excel operations Macros can automate tasks in Excel Macro.
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
Mastering Your Word Processing Skills
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Lab 9 – User Forms Design. User Forms What are user forms? –Known as dialog boxes –Major ways for getting user input An example of using user forms: Monthly.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
1 CS 106 Computing Fundamentals II Chapter 17 “Introduction To VBA” Herbert G. Mayer, PSU CS status 6/30/2013 Initial content copied verbatim from CS 106.
VBA for Excel. What is a spreadsheet? u An Excel spreadsheet is a set of worksheets  Each worksheets is made up of rows and columns of cells  Rows are.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Introduction to VBA MGMI Aug What is VBA? VBA = Visual Basic for Application Excel’s powerful built-in programming language An event-driven.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Week 8.  Recap  User Forms  Input Validation Message Boxes Input Boxes  Conversion Functions.
1 CS 106 Computing Fundamentals II Chapter 29 “Creating A User Form” Herbert G. Mayer, PSU CS Status 7/4/2013 Initial content copied verbatim from CS 106.
Chapter 12: Recording Macros Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Excel 1.Go to Skyward and open a class that you teach. In the right hand corner click export, then open the excel file you have created. (Mac click on.
A guide to creating a power point display Essentials Ctl M =New Slide: a new slide can be inserted. It is placed after the slide that you are viewing.
Chapter 3 The Visual Basic Editor. Important Features of the VBE Alt-F11 will open the Visual Basic Editor. The Code window is to the right, Project Explorer.
How to get started with Excel VBA. We need to enable programming in Excel  the “Developer menu”
Learning How to Make a PowerPoint Presentation A tutorial for novice users.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Visual Basic CDA College Limassol Campus Lecture:Pelekanou Olga Semester C Week - 1.
The Object Model. You can think of the contents of an Excel application as a hierarchy of collections of objects, manipulated by code Each object can.
Showing the Developer Tab. Windows vs Mac This is one of the places where the Mac and Windows procedures are different. We’ll look at the Windows method.
Excel Macros 1 Macros or, How to Automate Part of Your Spreadsheet or Worksheet.
Intermacs Form Download Excel Tutorial Pivot Tables, Graphic Tools, Macros By: Devin Koehl.
1 CS 106 Computing Fundamentals II Chapter 210 “Adding Controls to User Forms” Herbert G. Mayer, PSU CS Status 7/4/2013 Initial content copied verbatim.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Visual Basic A Quick Tutorial VB Review for ACS 367.
Controls for Choices. Let’s look at a couple of new controls: option buttons and check boxes These controls are designed to be used when you want the.
If you don’t have Google Earth downloaded already, you can go to to get it.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Multiple Forms and Menus
Home Page - Can be customized by the user Clicking on preferences in the upper right allows you to customize you home page, this one is set to favorites.
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
Access Project 8 Using Visual Basic for Applications (VBA) and Creating Multi-Page Forms.
Excel in M.E. –Using add-ins
Microsoft Excel 101.
Chapter 7 Advanced Form Techniques
Chapter 2 – Introduction to the Visual Studio .NET IDE
DIRECTIONS: 1. Click Enable Editing in the yellow bar above.
A few tricks to take you beyond the basics of Microsoft Office 2007
Home Page - Can be customized by the user Clicking on preferences in the upper right allows you to customize you home page, this one is set to favorites.
Introduction to Visual Basic 2010
Presentation transcript:

Creating a User Form

A Better Interface Our programs can use input boxes for input and write on the spreadsheet page for output This works ok but is not very elegant or flexible VBA gives us a way to create a custom form to use as an interface for our program We’ll look at the Windows version first, then the Mac version

WINDOWS VERSION

To Get Started… Open a new workbook, go to the Developer tab, and click Visual Basic. In VBA, double click ThisWorkBook in the project window to show the code sheet, and type OptionExplicit. Then click the Insert UserForm icon, and choose UserForm

Things to Notice Your new user form. Grab the bottom corner and drag to make it bigger. The toolbox has items you can put on the user form. If you don’t see it, click the toolbox icon (highlighted above) Properties of the selected form or tool

Change the Name of the Form Name is the first property In the list. We will refer to the form by its name in our program.

Change the Caption Caption property Here’s the caption. The user will see it when using the form. The user will not see the name.

Other Properties There are plenty of other properties to play with. You can try them out. One fun one is the background color. Let’s set it to something other than white…

I made it yellow The BackColor property The colors are reached through the little down arrow at the right of the property line. System colors are the ones Windows is using for your system. The Palette gives you some other options.

Showing the Form Unless you make it happen, the form won’t show up in your spreadsheet program The line of code that makes the form show up is formName.Show Let’s make it show up when you open the workbook, using the Workbook_Open event procedure. Double click in the project window to get back to the ThisWorkbook project, and type the code. The close the workbook and reopen it

Here is the code…

My screen, after opening the workbook and enabling macros

MAC VERSION

To Get Started Go to the Developer tab and then to the VBA editor. Under the InsertMenu, click Userform.

The new userform Controls you can add to the userform Properties window showing Userform properties Showing it In the project

Changing the Properties Use the properties window to change the properties We’ll change the name to frmExample And we’ll make it bigger by changing the height to 450 and width to 600 We’ll also change the caption to “Welcome” And the backcolor to yellow

I couldn’t find a yellow I liked on the color wheel, so I used the “crayons” to select one

Here is the yellow form after I clicked OK.

Showing the form Right now there is nothing that makes the form show up when you are in the workbook. The command frmExample.Show makes it visible We could put this in a macro that is activated by clicking a button, but let’s put it in the special Workbook_Open macro that makes it show up when you open the workbook.

I double clicked here to get the code window for this workbook I typed my code here

The code I typed Option Explicit '***************************************** ' Show form frmExample when the workbook opens '***************************************** Sub Workbook_Open() frmExample.Show End Sub

Save and quit… I saved my workbook as a Macro-enabled (.xlsm) workbook and then quit Excel The next slide shows what I got when I re- opened the workbook and enabled macros

The user form caption