SlideShare une entreprise Scribd logo
1  sur  95
Excel Chapter 7 Using Macros and Visual  Basic for Applications (VBA) with Excel
Objectives Use passwords to assign protected and unprotected status to a worksheet Use the macro recorder to create a macro Execute a macro and view and print code for a macro Understand Visual Basic for Applications (VBA) code and explain event-driven programs Customize the Quick Access Toolbar by adding a button © OpenCastLabs Consulting. www.opencast-labs.com
Objectives Add controls, such as command buttons, scroll bars, check boxes, and spin buttons to a worksheet Assign properties to controls Use VBA to write a procedure to automate data entry into a worksheet Understand Do-While and If-Then-Else statements Review a digital signature on a workbook © OpenCastLabs Consulting. www.opencast-labs.com
Plan Ahead Ascertain the steps needed to create a macro Create the user interface. In this chapter, two separate user interfaces are created that automate the entry of the employee’s investment model data Determine properties for controls in the user interface Establish the Visual Basic code needed for each control Evaluate the completed user interface through testing © OpenCastLabs Consulting. www.opencast-labs.com
Starting Excel and Opening a Workbook Start Excel Open the file Caliber from the Data Files for Students and then save the workbook using the file name, Caliber Steel If the Excel window is not maximized, double-click its title bar to maximize it If the worksheet window in Excel is not maximized, click the Maximize button next to the Close button on its title bar to maximize the worksheet within Excel © OpenCastLabs Consulting. www.opencast-labs.com
Starting Excel and Opening a Workbook © OpenCastLabs Consulting. www.opencast-labs.com
Entering Data in a Selected Range of Cells Select the range D5:D10. In cell D5, type Ali Kunar as the employee name and then press the ENTER key In cell D6, type 68400 as the annual salary and then press the ENTER key In cell D7, type 9% as the employee investment percentage and then press the ENTER key In cell D8, type 6% as the employer match percentage and then press the ENTER key In cell D9, type 8% as the annual return and then press the ENTER key In cell D10, type 25 as the years of service and then press the ENTER key to display the new future value of $813,127.57 in cell F10 Click cell H5 to remove the selection from the range D5:D10. You may have to scroll down the worksheet to refresh the pointer in the range B16:B24 © OpenCastLabs Consulting. www.opencast-labs.com
Entering Data in a Selected Range of Cells © OpenCastLabs Consulting. www.opencast-labs.com
Undoing a Group of Entries Using the Undo Button Click the Undo button arrow on the Quick Access Toolbar  When the Undo list appears, drag from the top down through Ali Kunar and then release the left mouse button to change the range D5:D10 back to its original values. Click cell H5. You may have to scroll down the worksheet to refresh the pointer in the range B16:B24 © OpenCastLabs Consulting. www.opencast-labs.com
Undoing a Group of Entries Using the Undo Button © OpenCastLabs Consulting. www.opencast-labs.com
Un-protecting a Password-Protected Worksheet Click the Review tab on the Ribbon Click the Unprotect Sheet button to display the Unprotect Sheet dialog box When the Unprotect Sheet dialog box appears, type caliber in the Password text box  Click the OK button to unprotect the 401(k) Investment Model worksheet © OpenCastLabs Consulting. www.opencast-labs.com
Un-protecting a Password-Protected Worksheet © OpenCastLabs Consulting. www.opencast-labs.com
Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Click the Office Button to display the Office Button menu and then the Excel Options button to display the Excel Options dialog box Click the Show Developer tab in the Ribbon check box Click the OK button in the Excel Options dialog box to display the Developer tab on the Ribbon. Click the Developer tab Click the Macro Security button on the Ribbon to display the Trust Center dialog box When the Trust Center dialog box appears, click the ‘Enable all macros’ option button to select it © OpenCastLabs Consulting. www.opencast-labs.com
Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Click the OK button to close the Macro Security dialog box Click the Office Button and then click Save As to display the Save As dialog box When the Save As dialog box appears, click the ‘Save as type’ box arrow and then click Excel Macro-Enabled Workbook in the ‘Save as type‘ list Click the Save button in the Save As dialog box to save the workbook as an Excel Macro-Enabled Workbook file type © OpenCastLabs Consulting. www.opencast-labs.com
Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook © OpenCastLabs Consulting. www.opencast-labs.com
Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option If necessary, click the Developer tab on the Ribbon Click the Record Macro button on the Ribbon to display the Record Macro dialog box When the Record Macro dialog box appears, type PrintPortrait in the Macro name text box Type r in the Shortcut key text box to set the shortcut key for the macro to CTRL+R Make sure the ‘Store macro in‘ box displays This Workbook and then type Macro prints worksheet in portrait orientation on one page in the Description text box © OpenCastLabs Consulting. www.opencast-labs.com
Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option Click the OK button to begin recording the macro and cause the Record Macro button to become the Stop Recording button Click the Page Layout tab on the Ribbon Click the Page Setup Dialog Box Launcher to display the Page Setup dialog box When the Page Setup dialog box displays, click the Page tab. If necessary, click Portrait in the Orientation area, and then click Fit to in the Scaling area Click the Print button in the Page Setup dialog box © OpenCastLabs Consulting. www.opencast-labs.com
Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option When the Print dialog box displays, click the OK button to print the worksheet Click the Page Setup Dialog Box Launcher to display the Page Setup dialog box If necessary, when the Page Setup dialog box displays, click the Page tab; click Landscape in the Orientation area; click Adjust to in the Scaling area; and then, if necessary, type 100 in the % normal size box Click the OK button to close the Page Setup dialog box Click the Developer tab on the Ribbon and then click the Stop Recording button to stop recording the worksheet activities © OpenCastLabs Consulting. www.opencast-labs.com
Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option © OpenCastLabs Consulting. www.opencast-labs.com
Password-Protecting the Worksheet, Saving the Workbook and Closing the Workbook Click the Review tab on the Ribbon, and then click the Protect Sheet button on the Ribbon. When the Protect Sheet dialog box appears, type caliber in the ‘Password to unprotect sheet’ text box and then click the OK button. When the Confirm Password dialog box is displayed, type caliber and then click the OK button Click the Office Button and then click Save As. When the Save As dialog box is displayed, type Caliber Steel1 in the File name text box. Make sure UDISK (E:) displays in the Save in box and then click the Save button in the Save As dialog box Click the workbook’s Close button on the right side of its menu bar to close the workbook and leave Excel active © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Macro Security Level to Medium Click the Developer tab on the Ribbon Click the Macro Security button on the Ribbon to display the Trust Center dialog box Click the ‘Disable all macros with notification’ option button Click the OK button in the Trust Center dialog box to close it © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Macro Security Level to Medium © OpenCastLabs Consulting. www.opencast-labs.com
Opening a Workbook with a Macro and Executing the Macro With Excel active, open the Caliber Steel1 workbook Click the Options button in the Security Warning box to display the Microsoft Office Security Options dialog box Click the ‘Enable this content’ option button to select it Click the OK button When the CaliberSteel1 workbook opens, press CTRL+R to run the macro and print the worksheet © OpenCastLabs Consulting. www.opencast-labs.com
Opening a Workbook with a Macro and Executing the Macro © OpenCastLabs Consulting. www.opencast-labs.com
Viewing and Printing a Macro’s VBA Code Click the Developer tab on the Ribbon Click the Macros button on the Ribbon to display the Macro dialog box If necessary, when the Macro dialog box is displayed, click PrintPortrait in the Macro name list Click the Edit button to start the Microsoft Visual Basic Editor Use the scroll bar to scroll through the VBA code © OpenCastLabs Consulting. www.opencast-labs.com
Viewing and Printing a Macro’s VBA Code When you are finished, click File on the menu bar Click Print When the Print – VBA Project dialog box is displayed, click the OK button to print the macro code Click the Microsoft Visual Basic Editor Close button on the right side of the title bar © OpenCastLabs Consulting. www.opencast-labs.com
Viewing and Printing a Macro’s VBA Code © OpenCastLabs Consulting. www.opencast-labs.com
Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button Right-click anywhere on the Quick Access Toolbar to display the shortcut menu Click the Customize Quick Access Toolbar command on the shortcut menu to display the Customize the Quick Access Toolbar page of the Excel Options dialog box Click the ‘Choose commands from’ box arrow Click Macros in the ‘Choose commands from’ list to display a list of macros If necessary, click the PrintPortait macro to select it Click the Add button to add the PrintPortrait macro to the Customize Quick Access Toolbar list © OpenCastLabs Consulting. www.opencast-labs.com
Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button Click the Modify button to display the Modify Button dialog box Click the printer icon (column 5, row 2) in the Symbol list Click the OK button to assign the printer icon to the new command and to close the Modify Button dialog box Click the OK button in the Excel Options dialog box to close it Point to the PrintPortrait button on the Quick Access Toolbar to display the ScreenTip for the button © OpenCastLabs Consulting. www.opencast-labs.com
Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button © OpenCastLabs Consulting. www.opencast-labs.com
Un-protecting a Password-Protected Worksheet With the Caliber Steel1 workbook open, click the Review tab on the Ribbon, and then click the Unprotect Sheet button on the Ribbon When the Unprotect Sheet dialog box appears, type caliber as the password and then click the OK button to unprotect the worksheet © OpenCastLabs Consulting. www.opencast-labs.com
Adding a Command Button Control to the Worksheet Click the Developer tab on the Ribbon Click the Insert button on the Ribbon to display the Controls gallery Click the Command Button button in the ActiveX area of the Controls gallery (column 1, row 1 of ActiveX area) to switch to Design mode Move the mouse pointer (a crosshair) to the upper-left corner of cell H5  Drag the mouse pointer so the rectangle defining the button area appears and hold Release the left mouse button to add the Command Button control with the default caption CommandButton1 © OpenCastLabs Consulting. www.opencast-labs.com
Adding a Command Button Control to the Worksheet © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Command Button Control Properties With the Command Button control selected and Excel in Design mode, click the Properties button on the Ribbon to open the Properties window for the Command Button control If necessary, when the Properties window opens, click the Alphabetic tab, click Caption in the Properties list, and then type New Data as the caption Click ForeColorin the Properties list, click the ForeColor arrow, and then click the Palette tab © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Command Button Control Properties Click blue (column 7, row 3) on the ForeColor palette Click Font in the Properties list and then click the Font button When the Font dialog box appears, click Bold in the Font style list and 12 in the Size list Click the OK button to display the Command Button control. If necessary, drag the lower-right corner of the Properties window to make all of the properties display in the window © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Command Button Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
Entering the New Data Button Procedure Using the Visual Basic Editor With the New Data button selected and Excel in Design mode, point to the View Code button on the Ribbon Click the View Code button on the Ribbon to start the Microsoft Visual Basic Editor When the Microsoft Visual Basic Editor starts, if the Project Explorer window appears on the left, click its Close button If necessary, double-click the title bar to maximize the Microsoft Visual Basic Editor window If necessary, double-click the title bar of the Microsoft Visual Basic window to maximize it © OpenCastLabs Consulting. www.opencast-labs.com
Entering the New Data Button Procedure Using the Visual Basic Editor Click to the left of the letter P in the word Private on the first line and press the ENTER key to add a blank line before the Sub statement Move the insertion point to the blank line and then type the seven comment statements (lines 1 through 7) in Table 7–2 on page EX 558. Make sure you enter an apostrophe (‘) at the beginning of each comment line Press the ENTER key to start a new line Position the insertion point on the blank line between the Sub and End Sub statements © OpenCastLabs Consulting. www.opencast-labs.com
Entering the New Data Button Procedure Using the Visual Basic Editor Enter lines 9 through 16 in Table 7–2. For clarity, indent all lines between the Sub statement and End Sub statement by three spaces Click the Close button on the right side of the Microsoft Visual Basic title bar to return to the worksheet Click the Close button on the right side of the Properties window Click the Design Mode button on the Ribbon to return to Run mode © OpenCastLabs Consulting. www.opencast-labs.com
Entering the New Data Button Procedure Using the Visual Basic Editor © OpenCastLabs Consulting. www.opencast-labs.com
Entering 401 (k) Investment Model Data Using the New Data Button Click the New Data button When Excel displays the first Enter dialog box with the prompt message, Employee Name?, type Millie Jenkins in the text box Click the OK button or press the ENTER key When Excel displays the next Enter dialog box with the prompt message, Annual Salary?, type 87200 in the text box Click the OK button When Excel displays the next Enter dialog box with the prompt message, Employee Investment in %?, type 6% in the text box, making certain to type the percent (%) sign © OpenCastLabs Consulting. www.opencast-labs.com
Entering 401 (k) Investment Model Data Using the New Data Button Click the OK button When Excel displays the next Enter dialog box with the prompt message, Employer Match in %?, type 3% in the text box Click the OK button When Excel displays the next Enter dialog box with the prompt message, Annual Return in %?, type 9% in the text box Click the OK button to assign 9.00% to cell D9 When Excel displays the next Enter dialog box with the prompt message, Years of Service?, type 20 in the text box Click the OK button to display the results for Millie Jenkins in the range F6:F10 © OpenCastLabs Consulting. www.opencast-labs.com
Entering 401 (k) Investment Model Data Using the New Data Button © OpenCastLabs Consulting. www.opencast-labs.com
Protecting a Worksheet and Saving the Workbook Click the Review tab on the Ribbon, and then click the Protect Sheet button on the Ribbon When the Protect Sheet dialog box appears, type caliber in the ‘Password to unprotect sheet’ text box and then click the OK button. When the Confirm Password dialog box appears, type caliber and then click the OK button Click the Office Button and then click Save As on the Office Button menu. When the Save As dialog box is displayed, type Caliber Steel2 in the File name text box. Make sure UDISK 2.0 (E:) displays in the Address bar and then click the Save button Click the Close button on the right side of the title bar to close the Caliber Steel2 workbook © OpenCastLabs Consulting. www.opencast-labs.com
Opening a Workbook and Un-protecting a Worksheet Open the Caliber Steel1 workbook saved in Phase 1 of this chapter Click the Options button in the Security Warning box. When the Microsoft Office Security Options dialog box appears, click the ‘Enable this content’ option button and then click the OK button to close the dialog box Click the Office Button and then click Save As on the Office Button menu. When the Save As dialog box is displayed, type Caliber Steel3 in the File name text box and then click the Save button in the Save As dialog box Click the Review tab on the Ribbon and then click the Unprotect Sheet button on the Ribbon. When the Unprotect Sheet dialog box appears, type caliber in the Password text box, and then click the OK button to unprotect the worksheet © OpenCastLabs Consulting. www.opencast-labs.com
Adding Controls to a User Interface Select the range H5:L24 Click the Fill Color button arrow on the Home tab on the Ribbon and then click White, Background 1, Darker 25% (column 1, row 4) on the Fill Color palette Click the Borders button arrow on the Ribbon and then click Thick Box Border on the Borders palette Click the Developer tab on the Ribbon Click the Insert button on the Ribbon, click the Command Button button in the ActiveX area in the Controls gallery, and then drag the mouse pointer so the control displays © OpenCastLabs Consulting. www.opencast-labs.com
Adding Controls to a User Interface Click the Insert button on the Ribbon, click the Scroll Bar button in the ActiveX area in the Controls gallery, and then move the mouse pointer to approximately the left of cell I12 Drag the mouse pointer so the Scroll Bar control displays Point to the Scroll Bar control Hold down the CTRL key and drag a copy of the Scroll Bar control to the location. It is important that you release the left mouse button before you release the CTRL key Click the Insert button on the Ribbon, click the Check Box button in the ActiveX area in the Controls gallery, and then move the mouse pointer to the upper-left corner of the location of the Check Box control  Drag the mouse pointer so the rectangle defining the Check Box control area displays with the word CheckBox1 showing © OpenCastLabs Consulting. www.opencast-labs.com
Adding Controls to a User Interface Click the Insert button on the Ribbon, click the Spin Button button in the ActiveX area in the Controls gallery, and then move the mouse pointer to the upper-left corner of the location of the Spin Button control Drag the mouse pointer so the rectangle defining the Spin Button control area displays Point to the Spin Button control in the Personalization Center Hold down the CTRL key and drag a copy of the Spin Button control to the second location. It is important that you release the left mouse button before you release the CTRL key Click the Insert button on the Ribbon, click the Label button in the ActiveX area in the Controls gallery, and then move the mouse pointer to the left of the first Scroll Bar control below the CommandButton1 button © OpenCastLabs Consulting. www.opencast-labs.com
Adding Controls to a User Interface Drag the mouse pointer so the rectangle defining the Label control displays Point to the Label control Hold down the CTRL key and then drag a copy of the Label control created in Step 7 to the center of cell J3. While holding down the CTRL key, drag the newly copied Label control to the next location where a Label control is required. Continue in this fashion until you have a total of 11 Label controls © OpenCastLabs Consulting. www.opencast-labs.com
Adding Controls to a User Interface © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls With Excel in Design mode, click the Label control in the top-right of the user interface Hold down the SHIFT key and then one at a time click the Check Box control and all Label controls except the title Label control Release the SHIFT key Click the Properties button on the Ribbon When the Properties window opens, click Back-Color; if necessary, click the Back-Color box arrow; and then click the Palette tab © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls Click the White, Background 1, Darker 25% (column 1, row 3) color on the BackColor palette to add a gray background to the selected controls Click Font in the Properties window and then click the Font button When the Fontdialog box appears, click Bold in the Font style list and click 12 in the Size list Click the OK button Click anywhere in the Personalization Center area to deselect the Label controls and Check Box control Click the Label control to the left of the first (Employee Investment) Scroll Bar control © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls Click Caption in the Properties window and then type 0 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 – fmTextAlignCenter Click the Label control to the right of the first Scroll Bar control Click Caption in the Properties window and then type 13 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls If necessary, resize the Label control so the caption 13 is visible Click the Label control above the first Scroll Bar control Click Caption in the Properties window and then type Employee Investment as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Resize the Label control so the caption Employee Investment is visible © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls Click the Label control to the left of the second Scroll Bar control Click Caption in the Properties window and then type 0 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Click the Label control on the right side of the second Scroll Bar control Click Caption in the Properties window and then type 6 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls Click the Label control above the Personalization Center area Click Caption in the Properties window and then type Personalization Center as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Change the font style to 18-point, bold, and red Resize the Label control so the entire caption shows Select the range H2:L3 Click the Home tab on the Ribbon. Click the Borders button arrow on the Ribbon and then click Thick Box Border in the Borders gallery Click the Developer tab on the Ribbon © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls Click the Label control directly above the second Scroll Bar Click Caption in the Properties window and then type Employer Match as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Resize the Label control so the entire caption shows Click the Label control to the far left of the top Spin Button control Click Caption inthe Properties window and then type Annual Return (1% to 20%) as the caption © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls Click TextAlign in the Properties window, click the TextAlign box arrow, and then, if necessary, click 1 - fmTextAlignLeft Resize the Label control so the entire caption shows Click the Label control to the far left of the second Spin Button control Click Caption in the Properties window and then type Years of Service (1 to 45 years) as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 1 - fmTextAlignLeft Resize the Label control so the entire caption shows © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties of the Labe Controls and Checking Box Controls © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Command Button Control Properties With Excel in Design mode, click the Command Button control in the Personalization Center Click Caption in the Properties window and then type Enter Name and Salary as the caption Click ForeColor, click the ForeColor box arrow, and then click the Palette tab Click red (row 4, column 2) on the ForeColor palette Click Font in the Properties window and then click the Font button When the Font dialog box appears, click Bold in the Font style list, click 12 in the Size list, and then click the OK button Resize the Command Button control so that the entire caption shows © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Command Button Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Employee Investment Scroll Bar Control Properties With Excel in Design mode, click the Employee Investment Scroll Bar control Click (Name) in the Properties window and then type scrEmployeeInvest as the name If necessary, change the LargeChange property to 100, the Max property to 1300, the Min property to 0, and the SmallChange property to 50 © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Employee Investment Scroll Bar Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Employer Match Scroll bar Control Properties With Excel in Design mode, click the Employer Match Scroll Bar control Click (Name) in the Properties window and then type scrEmployerMatch as the name Change the LargeChange property to 100, the Max property to 600, the Min property to 0, and the SmallChange property to 25 © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Employer Match Scroll bar Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Check Box Control Properties With Excel in Design mode, click the Check Box control Click (Name) in the Properties window and then type chkEmployerMatch as the name Click Alignment in the Properties window and then click 0 - fmAlignmentLeft Click Caption in the Properties window and then type Include Employer Match? as the caption  Click SpecialEffect, click the box arrow in the Properties window, and then click 0 - fmButtonEffectFlat Click Value in the Properties window and then type True as the value Resize the Check Box control so the entire caption shows © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Check Box Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties for the Annual Return and Years of Service Spin Button Controls With Excel in Design mode, click the Annual Return Spin Button control Click (Name) in the Properties window and then type spnAnnualReturn as the name If necessary, change the Max property to 2500, the Min property to 0, and the SmallChange property to 25 Click the Years of Service Spin Button control Click (Name) in the Properties window and then type spnYearsofService as the name Change the Max property to 45, the Min property to 1, and the SmallChange property to 1 © OpenCastLabs Consulting. www.opencast-labs.com
Setting Properties for the Annual Return and Years of Service Spin Button Controls © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Variable Label Control Properties With Excel in Design mode, click the Label control to the left of the Annual Return Spin Button control Click (Name) in the Properties window and then type lblAnnualReturn as the name Click Caption in the Properties window and then type 5% as the caption Change the BorderStyle property to 1 - fmBorderStyleSingle Change the BackColor property to white Change the TextAlign property to 3 - fmTextAlignRight Resize the Label control © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Variable Label Control Properties Click the Label control to the left of the Years of Service Spin Button control Click (Name) in the Properties window and then type lblYearsofService as the name Click Caption in the Properties window and then type 10 as the caption Change the BorderStyle property to 1 - fmBorderStyleSingle Change the BackColor property to white Change the TextAlign property to 3 - fmTextAlignRight Resize the Label control  Click the Close button on the right side of the Properties window title bar © OpenCastLabs Consulting. www.opencast-labs.com
Setting the Variable Label Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
Resizing and Repositioning the Controls in the Personalization Center Click the Properties button on the Ribbon If necessary, drag the Properties window to the left side of the Excel window Click the Enter Name and Salary Command Button control Change its Top, Left, Height, and Width properties to those listed in Table 7–4 to display the Enter Name and Salary Command Button One at a time, select the controls in the Personalization Center and change their Top, Left, Height, and Width properties to those listed in Table 7–4 Close the Properties window and then deselect the Years of Service (1 to 45 years) label by clicking cell A1 Click the Save button on the Quick Access Toolbar to save the workbook using the file name, Caliber Steel3 © OpenCastLabs Consulting. www.opencast-labs.com
Resizing and Repositioning the Controls in the Personalization Center © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Enter Name and Salary Button Procedure With Excel in Design mode, click the View Code button on the Ribbon Click the Object box arrow at the top of the window and then click CommandButton1 in the alphabetical list Click before the P in Private and then press the ENTER key. Enter the lines 1 through 9 in Table 7–5 Click the blank line between the Sub and End Sub statements. Enter lines 11 through 22 in Table 7-5 being sure to indent each line of code by three spaces for readability © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Enter Name and Salary Button Procedure © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Employee Investment Scroll Bar Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click scrEmployeeInvest Enter the VBA code shown in Table 7–6 © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Employee Investment Scroll Bar Procedure © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Employer Match Check Box Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click chkEmployerMatch  Enter the VBA code shown in Table 7–7 © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Employer Match Check Box Procedure © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Employer Match Scroll Bar Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click scrEmployerMatch. Enter the VBA code shown in Table 7–8 © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Employer Match Scroll Bar Procedure © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Annual Return Spin Button Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click spnAnnualReturn Enter the VBA code shown in Table 7–9 © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Annual Return Spin Button Procedure © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Years of Service Spin Button Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click spnYearsofService Enter the VBA code shown in Table 7–10 © OpenCastLabs Consulting. www.opencast-labs.com
Entering the Years of Service Spin Button Procedure © OpenCastLabs Consulting. www.opencast-labs.com
Closing the Visual basic Editor, Protecting the Worksheet, and Saving the Workbook Click the Close button on the right side of the Visual Basic Editor title bar When the Excel window is visible, click the Design Mode button on the Ribbon to exit Design mode Click the Review tab on the Ribbon and then click the Protect Sheet button on the Ribbon When Excel displays the Protect Sheet dialog box, type caliber in the ‘Password to unprotect sheet’ text box. Verify the password when prompted and then click the OK button Click the Save button on the Quick Access Toolbar to save the workbook using the file name, Caliber Steel3 © OpenCastLabs Consulting. www.opencast-labs.com
Testing the Controls in the Personalization Center Click the Enter Name and Salary button in the Personalization Center When Excel displays the Enter dialog box with the prompt message, Employee Name?, type Gina Moira as the employee name When Excel displays the Enter dialog box with the prompt message, Annual Salary?, type the negative number –54500 as the annual salary When Excel displays the Enter dialog box with the prompt message, Annual salary must be > zero, type 54500 as the annual salary © OpenCastLabs Consulting. www.opencast-labs.com
Testing the Controls in the Personalization Center Use the Employee Investment scroll bar to change the value in cell D7 to 6% Click the Include Employer Match check box if it does not have a check mark Use the Employer Match scroll bar to change the value in cell D8 to 4% Click the Annual Return spin button arrows to change the value in cell D9 to 8.5% Click the Years of Service spin button arrows to change the value in cell D10 to 35 © OpenCastLabs Consulting. www.opencast-labs.com
Resetting the Quick Access Toolbar and Ribbon and Quitting Excel Right-click anywhere on the Quick Access Toolbar and then click Customize Quick Access Toolbar on the shortcut menu When the Excel Options dialog box appears, click the Reset button and then click the OK button in the Reset Customizations dialog box. Click the OK button to close the Excel Options dialog box Click the Office Button and then click the Excel Options button on the Office Button menu Click the ‘Show Developer tab in the Ribbon’ check box to remove the check mark and then click the OK button to close the Excel Options dialog box Click the Close button on the right side of the title bar If the Microsoft Office Excel dialog box appears, click the No button © OpenCastLabs Consulting. www.opencast-labs.com
Adding a Digital Signature to a Workbook Click the Insert tab on the Ribbon and then click the Signature Line button on the Ribbon. If the Microsoft Office Excel dialog box appears, click the OK button When the Signature Setup dialog box appears, type your name in the Suggested signer text box and then click the OK button When Excel adds the signature box to the workbook, right-click anywhere in the signature box and then click Sign on the shortcut menu When the Sign dialog box appears, type your name in the signature box or click the Select Image link to select a file that contains an image of your signature Click the OK button to digitally sign the document © OpenCastLabs Consulting. www.opencast-labs.com
Reviewing a Digital Signature on a Workbook Click the Office Button and then click Prepare on the Office Button menu Click View Signature on the Prepare submenu Select a name from the Valid signature list in the signature pane and then click the button arrow next to the name. When the shortcut menu appears, click Signature Details When you are finished reviewing the certificate, click the OK button in the Signature Details dialog box © OpenCastLabs Consulting. www.opencast-labs.com
Summary Use passwords to assign protected and unprotected status to a worksheet Use the macro recorder to create a macro Execute a macro and view and print code for a macro Understand Visual Basic for Applications (VBA) code and explain event-driven programs Customize the Quick Access Toolbar by adding a button © OpenCastLabs Consulting. www.opencast-labs.com
Summary Add controls, such as command buttons, scroll bars, check boxes, and spin buttons to a worksheet Assign properties to controls Use VBA to write a procedure to automate data entry into a worksheet Understand Do-While and If-Then-Else statements Review a digital signature on a workbook © OpenCastLabs Consulting. www.opencast-labs.com
Excel Chapter 7 Complete

Contenu connexe

Tendances

Learn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in DelhiLearn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in Delhiibinstitute0
 
Create formsexcel
Create formsexcelCreate formsexcel
Create formsexcelRavi Gajul
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application Raghu nath
 
Tutorials on Macro
Tutorials on MacroTutorials on Macro
Tutorials on MacroAnurag Deb
 
E learning excel vba programming lesson 2
E learning excel vba programming  lesson 2E learning excel vba programming  lesson 2
E learning excel vba programming lesson 2Vijay Perepa
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editorputiadetiara
 
Advance MS Excel
Advance MS ExcelAdvance MS Excel
Advance MS Excelacute23
 
Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBADCPS
 
Introduction to Excel VBA/Macros
Introduction to Excel VBA/MacrosIntroduction to Excel VBA/Macros
Introduction to Excel VBA/Macrosarttan2001
 
ICDL Advanced Excel 2010 - Tutorial
ICDL Advanced Excel 2010 - TutorialICDL Advanced Excel 2010 - Tutorial
ICDL Advanced Excel 2010 - TutorialMichael Lew
 
Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-Faina Fridman
 
Teaching Excel
Teaching ExcelTeaching Excel
Teaching Excelsam ran
 

Tendances (20)

Learn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in DelhiLearn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in Delhi
 
Create formsexcel
Create formsexcelCreate formsexcel
Create formsexcel
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application
 
VBA
VBAVBA
VBA
 
Tutorials on Macro
Tutorials on MacroTutorials on Macro
Tutorials on Macro
 
E learning excel vba programming lesson 2
E learning excel vba programming  lesson 2E learning excel vba programming  lesson 2
E learning excel vba programming lesson 2
 
Tugas testing
Tugas testingTugas testing
Tugas testing
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editor
 
Advance MS Excel
Advance MS ExcelAdvance MS Excel
Advance MS Excel
 
Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBA
 
VBA
VBAVBA
VBA
 
Project1 VB
Project1 VBProject1 VB
Project1 VB
 
Excel 2007
Excel 2007Excel 2007
Excel 2007
 
Ms Access
Ms AccessMs Access
Ms Access
 
Introduction to Excel VBA/Macros
Introduction to Excel VBA/MacrosIntroduction to Excel VBA/Macros
Introduction to Excel VBA/Macros
 
MS Excel 2013
MS Excel 2013MS Excel 2013
MS Excel 2013
 
ICDL Advanced Excel 2010 - Tutorial
ICDL Advanced Excel 2010 - TutorialICDL Advanced Excel 2010 - Tutorial
ICDL Advanced Excel 2010 - Tutorial
 
Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-
 
Teaching Excel
Teaching ExcelTeaching Excel
Teaching Excel
 
Excel300
Excel300Excel300
Excel300
 

En vedette

Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computersimran153
 
2016-03-08 What Now - Inevitability of Change
2016-03-08 What Now - Inevitability of Change2016-03-08 What Now - Inevitability of Change
2016-03-08 What Now - Inevitability of ChangeJessica Kaylor Morgan
 
Notes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsNotes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsWilliam Olivier
 
Programming inexcelvba anintroduction
Programming inexcelvba anintroductionProgramming inexcelvba anintroduction
Programming inexcelvba anintroductionOfun Emma
 
Belajar macro excel 2007
Belajar macro excel 2007Belajar macro excel 2007
Belajar macro excel 2007doni sandra
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Salim M
 

En vedette (9)

Excel y visual basic
Excel y visual basicExcel y visual basic
Excel y visual basic
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
 
2016-03-08 What Now - Inevitability of Change
2016-03-08 What Now - Inevitability of Change2016-03-08 What Now - Inevitability of Change
2016-03-08 What Now - Inevitability of Change
 
Notes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsNotes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculations
 
Programming inexcelvba anintroduction
Programming inexcelvba anintroductionProgramming inexcelvba anintroduction
Programming inexcelvba anintroduction
 
Belajar macro excel 2007
Belajar macro excel 2007Belajar macro excel 2007
Belajar macro excel 2007
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0
 

Similaire à Excel chapter-7

Learn Vba excel 2007
Learn Vba excel 2007Learn Vba excel 2007
Learn Vba excel 2007Steve Johnson
 
Form4 cd4
Form4 cd4Form4 cd4
Form4 cd4smktsj2
 
Recording and running macros in the office application
Recording and running macros in the office applicationRecording and running macros in the office application
Recording and running macros in the office applicationputiadetiara
 
Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3Astrid yolanda
 
Spreadsheet Analytical Tools
Spreadsheet Analytical ToolsSpreadsheet Analytical Tools
Spreadsheet Analytical ToolsJoselito Perez
 
Unit c adobe dreamweaver cs6
Unit c adobe dreamweaver cs6Unit c adobe dreamweaver cs6
Unit c adobe dreamweaver cs6Krista Lawrence
 
Creating reports in oracle e business suite using xml publisher
Creating reports in oracle e business suite using xml publisherCreating reports in oracle e business suite using xml publisher
Creating reports in oracle e business suite using xml publisherSamchi Fouzee
 
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007ITVAMP, LLC
 
Sap tutorial for dynamics
Sap tutorial for dynamicsSap tutorial for dynamics
Sap tutorial for dynamicscolosimoricardo
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesSami Mut
 
Bcsl 013 solved-assignment-2019-20 without
Bcsl 013   solved-assignment-2019-20 withoutBcsl 013   solved-assignment-2019-20 without
Bcsl 013 solved-assignment-2019-20 withoutAbhinavSingh732
 
Sap tutorial for dynamics
Sap tutorial for dynamicsSap tutorial for dynamics
Sap tutorial for dynamicsNoor Mohammed
 

Similaire à Excel chapter-7 (20)

Learn Vba excel 2007
Learn Vba excel 2007Learn Vba excel 2007
Learn Vba excel 2007
 
Form4 cd4
Form4 cd4Form4 cd4
Form4 cd4
 
Recording and running macros in the office application
Recording and running macros in the office applicationRecording and running macros in the office application
Recording and running macros in the office application
 
Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3
 
Excel chapter-6
Excel chapter-6Excel chapter-6
Excel chapter-6
 
Notacd04
Notacd04Notacd04
Notacd04
 
Notacd04
Notacd04Notacd04
Notacd04
 
OpenCastLabs Excel chapter-3
OpenCastLabs Excel chapter-3OpenCastLabs Excel chapter-3
OpenCastLabs Excel chapter-3
 
Spreadsheet Analytical Tools
Spreadsheet Analytical ToolsSpreadsheet Analytical Tools
Spreadsheet Analytical Tools
 
Unit c adobe dreamweaver cs6
Unit c adobe dreamweaver cs6Unit c adobe dreamweaver cs6
Unit c adobe dreamweaver cs6
 
Creating reports in oracle e business suite using xml publisher
Creating reports in oracle e business suite using xml publisherCreating reports in oracle e business suite using xml publisher
Creating reports in oracle e business suite using xml publisher
 
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
 
Excel chapter-9
Excel chapter-9Excel chapter-9
Excel chapter-9
 
Excel chapter-4
Excel chapter-4Excel chapter-4
Excel chapter-4
 
Sap tutorial for dynamics
Sap tutorial for dynamicsSap tutorial for dynamics
Sap tutorial for dynamics
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slides
 
Orcad Capture - Schematic Design Tutorial
Orcad Capture - Schematic Design TutorialOrcad Capture - Schematic Design Tutorial
Orcad Capture - Schematic Design Tutorial
 
Bcsl 013 solved-assignment-2019-20 without
Bcsl 013   solved-assignment-2019-20 withoutBcsl 013   solved-assignment-2019-20 without
Bcsl 013 solved-assignment-2019-20 without
 
Sap tutorial for dynamics
Sap tutorial for dynamicsSap tutorial for dynamics
Sap tutorial for dynamics
 

Plus de OpenCastLabs Consulting

Plus de OpenCastLabs Consulting (7)

People & HR Analytics Course - OpenCastLabs Consulting.
People & HR Analytics Course - OpenCastLabs Consulting.People & HR Analytics Course - OpenCastLabs Consulting.
People & HR Analytics Course - OpenCastLabs Consulting.
 
Advanced excel training nairobi 18th & 19th
Advanced excel training   nairobi 18th & 19thAdvanced excel training   nairobi 18th & 19th
Advanced excel training nairobi 18th & 19th
 
Excel chapter-5
Excel chapter-5Excel chapter-5
Excel chapter-5
 
OpenCastLabs Excel chapter-2
OpenCastLabs Excel chapter-2OpenCastLabs Excel chapter-2
OpenCastLabs Excel chapter-2
 
OpenCastLabs Excel chapter-1
OpenCastLabs Excel chapter-1OpenCastLabs Excel chapter-1
OpenCastLabs Excel chapter-1
 
Excel chapter-8
Excel chapter-8Excel chapter-8
Excel chapter-8
 
Customer Satisfaction Survey
Customer Satisfaction SurveyCustomer Satisfaction Survey
Customer Satisfaction Survey
 

Dernier

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Dernier (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

Excel chapter-7

  • 1. Excel Chapter 7 Using Macros and Visual Basic for Applications (VBA) with Excel
  • 2. Objectives Use passwords to assign protected and unprotected status to a worksheet Use the macro recorder to create a macro Execute a macro and view and print code for a macro Understand Visual Basic for Applications (VBA) code and explain event-driven programs Customize the Quick Access Toolbar by adding a button © OpenCastLabs Consulting. www.opencast-labs.com
  • 3. Objectives Add controls, such as command buttons, scroll bars, check boxes, and spin buttons to a worksheet Assign properties to controls Use VBA to write a procedure to automate data entry into a worksheet Understand Do-While and If-Then-Else statements Review a digital signature on a workbook © OpenCastLabs Consulting. www.opencast-labs.com
  • 4. Plan Ahead Ascertain the steps needed to create a macro Create the user interface. In this chapter, two separate user interfaces are created that automate the entry of the employee’s investment model data Determine properties for controls in the user interface Establish the Visual Basic code needed for each control Evaluate the completed user interface through testing © OpenCastLabs Consulting. www.opencast-labs.com
  • 5. Starting Excel and Opening a Workbook Start Excel Open the file Caliber from the Data Files for Students and then save the workbook using the file name, Caliber Steel If the Excel window is not maximized, double-click its title bar to maximize it If the worksheet window in Excel is not maximized, click the Maximize button next to the Close button on its title bar to maximize the worksheet within Excel © OpenCastLabs Consulting. www.opencast-labs.com
  • 6. Starting Excel and Opening a Workbook © OpenCastLabs Consulting. www.opencast-labs.com
  • 7. Entering Data in a Selected Range of Cells Select the range D5:D10. In cell D5, type Ali Kunar as the employee name and then press the ENTER key In cell D6, type 68400 as the annual salary and then press the ENTER key In cell D7, type 9% as the employee investment percentage and then press the ENTER key In cell D8, type 6% as the employer match percentage and then press the ENTER key In cell D9, type 8% as the annual return and then press the ENTER key In cell D10, type 25 as the years of service and then press the ENTER key to display the new future value of $813,127.57 in cell F10 Click cell H5 to remove the selection from the range D5:D10. You may have to scroll down the worksheet to refresh the pointer in the range B16:B24 © OpenCastLabs Consulting. www.opencast-labs.com
  • 8. Entering Data in a Selected Range of Cells © OpenCastLabs Consulting. www.opencast-labs.com
  • 9. Undoing a Group of Entries Using the Undo Button Click the Undo button arrow on the Quick Access Toolbar When the Undo list appears, drag from the top down through Ali Kunar and then release the left mouse button to change the range D5:D10 back to its original values. Click cell H5. You may have to scroll down the worksheet to refresh the pointer in the range B16:B24 © OpenCastLabs Consulting. www.opencast-labs.com
  • 10. Undoing a Group of Entries Using the Undo Button © OpenCastLabs Consulting. www.opencast-labs.com
  • 11. Un-protecting a Password-Protected Worksheet Click the Review tab on the Ribbon Click the Unprotect Sheet button to display the Unprotect Sheet dialog box When the Unprotect Sheet dialog box appears, type caliber in the Password text box Click the OK button to unprotect the 401(k) Investment Model worksheet © OpenCastLabs Consulting. www.opencast-labs.com
  • 12. Un-protecting a Password-Protected Worksheet © OpenCastLabs Consulting. www.opencast-labs.com
  • 13. Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Click the Office Button to display the Office Button menu and then the Excel Options button to display the Excel Options dialog box Click the Show Developer tab in the Ribbon check box Click the OK button in the Excel Options dialog box to display the Developer tab on the Ribbon. Click the Developer tab Click the Macro Security button on the Ribbon to display the Trust Center dialog box When the Trust Center dialog box appears, click the ‘Enable all macros’ option button to select it © OpenCastLabs Consulting. www.opencast-labs.com
  • 14. Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Click the OK button to close the Macro Security dialog box Click the Office Button and then click Save As to display the Save As dialog box When the Save As dialog box appears, click the ‘Save as type’ box arrow and then click Excel Macro-Enabled Workbook in the ‘Save as type‘ list Click the Save button in the Save As dialog box to save the workbook as an Excel Macro-Enabled Workbook file type © OpenCastLabs Consulting. www.opencast-labs.com
  • 15. Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook © OpenCastLabs Consulting. www.opencast-labs.com
  • 16. Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option If necessary, click the Developer tab on the Ribbon Click the Record Macro button on the Ribbon to display the Record Macro dialog box When the Record Macro dialog box appears, type PrintPortrait in the Macro name text box Type r in the Shortcut key text box to set the shortcut key for the macro to CTRL+R Make sure the ‘Store macro in‘ box displays This Workbook and then type Macro prints worksheet in portrait orientation on one page in the Description text box © OpenCastLabs Consulting. www.opencast-labs.com
  • 17. Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option Click the OK button to begin recording the macro and cause the Record Macro button to become the Stop Recording button Click the Page Layout tab on the Ribbon Click the Page Setup Dialog Box Launcher to display the Page Setup dialog box When the Page Setup dialog box displays, click the Page tab. If necessary, click Portrait in the Orientation area, and then click Fit to in the Scaling area Click the Print button in the Page Setup dialog box © OpenCastLabs Consulting. www.opencast-labs.com
  • 18. Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option When the Print dialog box displays, click the OK button to print the worksheet Click the Page Setup Dialog Box Launcher to display the Page Setup dialog box If necessary, when the Page Setup dialog box displays, click the Page tab; click Landscape in the Orientation area; click Adjust to in the Scaling area; and then, if necessary, type 100 in the % normal size box Click the OK button to close the Page Setup dialog box Click the Developer tab on the Ribbon and then click the Stop Recording button to stop recording the worksheet activities © OpenCastLabs Consulting. www.opencast-labs.com
  • 19. Recording a Macro to Print the Worksheet in Portrait Orientation Using the Fit to Option © OpenCastLabs Consulting. www.opencast-labs.com
  • 20. Password-Protecting the Worksheet, Saving the Workbook and Closing the Workbook Click the Review tab on the Ribbon, and then click the Protect Sheet button on the Ribbon. When the Protect Sheet dialog box appears, type caliber in the ‘Password to unprotect sheet’ text box and then click the OK button. When the Confirm Password dialog box is displayed, type caliber and then click the OK button Click the Office Button and then click Save As. When the Save As dialog box is displayed, type Caliber Steel1 in the File name text box. Make sure UDISK (E:) displays in the Save in box and then click the Save button in the Save As dialog box Click the workbook’s Close button on the right side of its menu bar to close the workbook and leave Excel active © OpenCastLabs Consulting. www.opencast-labs.com
  • 21. Setting the Macro Security Level to Medium Click the Developer tab on the Ribbon Click the Macro Security button on the Ribbon to display the Trust Center dialog box Click the ‘Disable all macros with notification’ option button Click the OK button in the Trust Center dialog box to close it © OpenCastLabs Consulting. www.opencast-labs.com
  • 22. Setting the Macro Security Level to Medium © OpenCastLabs Consulting. www.opencast-labs.com
  • 23. Opening a Workbook with a Macro and Executing the Macro With Excel active, open the Caliber Steel1 workbook Click the Options button in the Security Warning box to display the Microsoft Office Security Options dialog box Click the ‘Enable this content’ option button to select it Click the OK button When the CaliberSteel1 workbook opens, press CTRL+R to run the macro and print the worksheet © OpenCastLabs Consulting. www.opencast-labs.com
  • 24. Opening a Workbook with a Macro and Executing the Macro © OpenCastLabs Consulting. www.opencast-labs.com
  • 25. Viewing and Printing a Macro’s VBA Code Click the Developer tab on the Ribbon Click the Macros button on the Ribbon to display the Macro dialog box If necessary, when the Macro dialog box is displayed, click PrintPortrait in the Macro name list Click the Edit button to start the Microsoft Visual Basic Editor Use the scroll bar to scroll through the VBA code © OpenCastLabs Consulting. www.opencast-labs.com
  • 26. Viewing and Printing a Macro’s VBA Code When you are finished, click File on the menu bar Click Print When the Print – VBA Project dialog box is displayed, click the OK button to print the macro code Click the Microsoft Visual Basic Editor Close button on the right side of the title bar © OpenCastLabs Consulting. www.opencast-labs.com
  • 27. Viewing and Printing a Macro’s VBA Code © OpenCastLabs Consulting. www.opencast-labs.com
  • 28. Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button Right-click anywhere on the Quick Access Toolbar to display the shortcut menu Click the Customize Quick Access Toolbar command on the shortcut menu to display the Customize the Quick Access Toolbar page of the Excel Options dialog box Click the ‘Choose commands from’ box arrow Click Macros in the ‘Choose commands from’ list to display a list of macros If necessary, click the PrintPortait macro to select it Click the Add button to add the PrintPortrait macro to the Customize Quick Access Toolbar list © OpenCastLabs Consulting. www.opencast-labs.com
  • 29. Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button Click the Modify button to display the Modify Button dialog box Click the printer icon (column 5, row 2) in the Symbol list Click the OK button to assign the printer icon to the new command and to close the Modify Button dialog box Click the OK button in the Excel Options dialog box to close it Point to the PrintPortrait button on the Quick Access Toolbar to display the ScreenTip for the button © OpenCastLabs Consulting. www.opencast-labs.com
  • 30. Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button © OpenCastLabs Consulting. www.opencast-labs.com
  • 31. Un-protecting a Password-Protected Worksheet With the Caliber Steel1 workbook open, click the Review tab on the Ribbon, and then click the Unprotect Sheet button on the Ribbon When the Unprotect Sheet dialog box appears, type caliber as the password and then click the OK button to unprotect the worksheet © OpenCastLabs Consulting. www.opencast-labs.com
  • 32. Adding a Command Button Control to the Worksheet Click the Developer tab on the Ribbon Click the Insert button on the Ribbon to display the Controls gallery Click the Command Button button in the ActiveX area of the Controls gallery (column 1, row 1 of ActiveX area) to switch to Design mode Move the mouse pointer (a crosshair) to the upper-left corner of cell H5 Drag the mouse pointer so the rectangle defining the button area appears and hold Release the left mouse button to add the Command Button control with the default caption CommandButton1 © OpenCastLabs Consulting. www.opencast-labs.com
  • 33. Adding a Command Button Control to the Worksheet © OpenCastLabs Consulting. www.opencast-labs.com
  • 34. Setting the Command Button Control Properties With the Command Button control selected and Excel in Design mode, click the Properties button on the Ribbon to open the Properties window for the Command Button control If necessary, when the Properties window opens, click the Alphabetic tab, click Caption in the Properties list, and then type New Data as the caption Click ForeColorin the Properties list, click the ForeColor arrow, and then click the Palette tab © OpenCastLabs Consulting. www.opencast-labs.com
  • 35. Setting the Command Button Control Properties Click blue (column 7, row 3) on the ForeColor palette Click Font in the Properties list and then click the Font button When the Font dialog box appears, click Bold in the Font style list and 12 in the Size list Click the OK button to display the Command Button control. If necessary, drag the lower-right corner of the Properties window to make all of the properties display in the window © OpenCastLabs Consulting. www.opencast-labs.com
  • 36. Setting the Command Button Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
  • 37. Entering the New Data Button Procedure Using the Visual Basic Editor With the New Data button selected and Excel in Design mode, point to the View Code button on the Ribbon Click the View Code button on the Ribbon to start the Microsoft Visual Basic Editor When the Microsoft Visual Basic Editor starts, if the Project Explorer window appears on the left, click its Close button If necessary, double-click the title bar to maximize the Microsoft Visual Basic Editor window If necessary, double-click the title bar of the Microsoft Visual Basic window to maximize it © OpenCastLabs Consulting. www.opencast-labs.com
  • 38. Entering the New Data Button Procedure Using the Visual Basic Editor Click to the left of the letter P in the word Private on the first line and press the ENTER key to add a blank line before the Sub statement Move the insertion point to the blank line and then type the seven comment statements (lines 1 through 7) in Table 7–2 on page EX 558. Make sure you enter an apostrophe (‘) at the beginning of each comment line Press the ENTER key to start a new line Position the insertion point on the blank line between the Sub and End Sub statements © OpenCastLabs Consulting. www.opencast-labs.com
  • 39. Entering the New Data Button Procedure Using the Visual Basic Editor Enter lines 9 through 16 in Table 7–2. For clarity, indent all lines between the Sub statement and End Sub statement by three spaces Click the Close button on the right side of the Microsoft Visual Basic title bar to return to the worksheet Click the Close button on the right side of the Properties window Click the Design Mode button on the Ribbon to return to Run mode © OpenCastLabs Consulting. www.opencast-labs.com
  • 40. Entering the New Data Button Procedure Using the Visual Basic Editor © OpenCastLabs Consulting. www.opencast-labs.com
  • 41. Entering 401 (k) Investment Model Data Using the New Data Button Click the New Data button When Excel displays the first Enter dialog box with the prompt message, Employee Name?, type Millie Jenkins in the text box Click the OK button or press the ENTER key When Excel displays the next Enter dialog box with the prompt message, Annual Salary?, type 87200 in the text box Click the OK button When Excel displays the next Enter dialog box with the prompt message, Employee Investment in %?, type 6% in the text box, making certain to type the percent (%) sign © OpenCastLabs Consulting. www.opencast-labs.com
  • 42. Entering 401 (k) Investment Model Data Using the New Data Button Click the OK button When Excel displays the next Enter dialog box with the prompt message, Employer Match in %?, type 3% in the text box Click the OK button When Excel displays the next Enter dialog box with the prompt message, Annual Return in %?, type 9% in the text box Click the OK button to assign 9.00% to cell D9 When Excel displays the next Enter dialog box with the prompt message, Years of Service?, type 20 in the text box Click the OK button to display the results for Millie Jenkins in the range F6:F10 © OpenCastLabs Consulting. www.opencast-labs.com
  • 43. Entering 401 (k) Investment Model Data Using the New Data Button © OpenCastLabs Consulting. www.opencast-labs.com
  • 44. Protecting a Worksheet and Saving the Workbook Click the Review tab on the Ribbon, and then click the Protect Sheet button on the Ribbon When the Protect Sheet dialog box appears, type caliber in the ‘Password to unprotect sheet’ text box and then click the OK button. When the Confirm Password dialog box appears, type caliber and then click the OK button Click the Office Button and then click Save As on the Office Button menu. When the Save As dialog box is displayed, type Caliber Steel2 in the File name text box. Make sure UDISK 2.0 (E:) displays in the Address bar and then click the Save button Click the Close button on the right side of the title bar to close the Caliber Steel2 workbook © OpenCastLabs Consulting. www.opencast-labs.com
  • 45. Opening a Workbook and Un-protecting a Worksheet Open the Caliber Steel1 workbook saved in Phase 1 of this chapter Click the Options button in the Security Warning box. When the Microsoft Office Security Options dialog box appears, click the ‘Enable this content’ option button and then click the OK button to close the dialog box Click the Office Button and then click Save As on the Office Button menu. When the Save As dialog box is displayed, type Caliber Steel3 in the File name text box and then click the Save button in the Save As dialog box Click the Review tab on the Ribbon and then click the Unprotect Sheet button on the Ribbon. When the Unprotect Sheet dialog box appears, type caliber in the Password text box, and then click the OK button to unprotect the worksheet © OpenCastLabs Consulting. www.opencast-labs.com
  • 46. Adding Controls to a User Interface Select the range H5:L24 Click the Fill Color button arrow on the Home tab on the Ribbon and then click White, Background 1, Darker 25% (column 1, row 4) on the Fill Color palette Click the Borders button arrow on the Ribbon and then click Thick Box Border on the Borders palette Click the Developer tab on the Ribbon Click the Insert button on the Ribbon, click the Command Button button in the ActiveX area in the Controls gallery, and then drag the mouse pointer so the control displays © OpenCastLabs Consulting. www.opencast-labs.com
  • 47. Adding Controls to a User Interface Click the Insert button on the Ribbon, click the Scroll Bar button in the ActiveX area in the Controls gallery, and then move the mouse pointer to approximately the left of cell I12 Drag the mouse pointer so the Scroll Bar control displays Point to the Scroll Bar control Hold down the CTRL key and drag a copy of the Scroll Bar control to the location. It is important that you release the left mouse button before you release the CTRL key Click the Insert button on the Ribbon, click the Check Box button in the ActiveX area in the Controls gallery, and then move the mouse pointer to the upper-left corner of the location of the Check Box control Drag the mouse pointer so the rectangle defining the Check Box control area displays with the word CheckBox1 showing © OpenCastLabs Consulting. www.opencast-labs.com
  • 48. Adding Controls to a User Interface Click the Insert button on the Ribbon, click the Spin Button button in the ActiveX area in the Controls gallery, and then move the mouse pointer to the upper-left corner of the location of the Spin Button control Drag the mouse pointer so the rectangle defining the Spin Button control area displays Point to the Spin Button control in the Personalization Center Hold down the CTRL key and drag a copy of the Spin Button control to the second location. It is important that you release the left mouse button before you release the CTRL key Click the Insert button on the Ribbon, click the Label button in the ActiveX area in the Controls gallery, and then move the mouse pointer to the left of the first Scroll Bar control below the CommandButton1 button © OpenCastLabs Consulting. www.opencast-labs.com
  • 49. Adding Controls to a User Interface Drag the mouse pointer so the rectangle defining the Label control displays Point to the Label control Hold down the CTRL key and then drag a copy of the Label control created in Step 7 to the center of cell J3. While holding down the CTRL key, drag the newly copied Label control to the next location where a Label control is required. Continue in this fashion until you have a total of 11 Label controls © OpenCastLabs Consulting. www.opencast-labs.com
  • 50. Adding Controls to a User Interface © OpenCastLabs Consulting. www.opencast-labs.com
  • 51. Setting Properties of the Labe Controls and Checking Box Controls With Excel in Design mode, click the Label control in the top-right of the user interface Hold down the SHIFT key and then one at a time click the Check Box control and all Label controls except the title Label control Release the SHIFT key Click the Properties button on the Ribbon When the Properties window opens, click Back-Color; if necessary, click the Back-Color box arrow; and then click the Palette tab © OpenCastLabs Consulting. www.opencast-labs.com
  • 52. Setting Properties of the Labe Controls and Checking Box Controls Click the White, Background 1, Darker 25% (column 1, row 3) color on the BackColor palette to add a gray background to the selected controls Click Font in the Properties window and then click the Font button When the Fontdialog box appears, click Bold in the Font style list and click 12 in the Size list Click the OK button Click anywhere in the Personalization Center area to deselect the Label controls and Check Box control Click the Label control to the left of the first (Employee Investment) Scroll Bar control © OpenCastLabs Consulting. www.opencast-labs.com
  • 53. Setting Properties of the Labe Controls and Checking Box Controls Click Caption in the Properties window and then type 0 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 – fmTextAlignCenter Click the Label control to the right of the first Scroll Bar control Click Caption in the Properties window and then type 13 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter © OpenCastLabs Consulting. www.opencast-labs.com
  • 54. Setting Properties of the Labe Controls and Checking Box Controls If necessary, resize the Label control so the caption 13 is visible Click the Label control above the first Scroll Bar control Click Caption in the Properties window and then type Employee Investment as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Resize the Label control so the caption Employee Investment is visible © OpenCastLabs Consulting. www.opencast-labs.com
  • 55. Setting Properties of the Labe Controls and Checking Box Controls Click the Label control to the left of the second Scroll Bar control Click Caption in the Properties window and then type 0 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Click the Label control on the right side of the second Scroll Bar control Click Caption in the Properties window and then type 6 as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter © OpenCastLabs Consulting. www.opencast-labs.com
  • 56. Setting Properties of the Labe Controls and Checking Box Controls Click the Label control above the Personalization Center area Click Caption in the Properties window and then type Personalization Center as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Change the font style to 18-point, bold, and red Resize the Label control so the entire caption shows Select the range H2:L3 Click the Home tab on the Ribbon. Click the Borders button arrow on the Ribbon and then click Thick Box Border in the Borders gallery Click the Developer tab on the Ribbon © OpenCastLabs Consulting. www.opencast-labs.com
  • 57. Setting Properties of the Labe Controls and Checking Box Controls Click the Label control directly above the second Scroll Bar Click Caption in the Properties window and then type Employer Match as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 2 - fmTextAlignCenter Resize the Label control so the entire caption shows Click the Label control to the far left of the top Spin Button control Click Caption inthe Properties window and then type Annual Return (1% to 20%) as the caption © OpenCastLabs Consulting. www.opencast-labs.com
  • 58. Setting Properties of the Labe Controls and Checking Box Controls Click TextAlign in the Properties window, click the TextAlign box arrow, and then, if necessary, click 1 - fmTextAlignLeft Resize the Label control so the entire caption shows Click the Label control to the far left of the second Spin Button control Click Caption in the Properties window and then type Years of Service (1 to 45 years) as the caption Click TextAlign in the Properties window, click the TextAlign box arrow, and then click 1 - fmTextAlignLeft Resize the Label control so the entire caption shows © OpenCastLabs Consulting. www.opencast-labs.com
  • 59. Setting Properties of the Labe Controls and Checking Box Controls © OpenCastLabs Consulting. www.opencast-labs.com
  • 60. Setting the Command Button Control Properties With Excel in Design mode, click the Command Button control in the Personalization Center Click Caption in the Properties window and then type Enter Name and Salary as the caption Click ForeColor, click the ForeColor box arrow, and then click the Palette tab Click red (row 4, column 2) on the ForeColor palette Click Font in the Properties window and then click the Font button When the Font dialog box appears, click Bold in the Font style list, click 12 in the Size list, and then click the OK button Resize the Command Button control so that the entire caption shows © OpenCastLabs Consulting. www.opencast-labs.com
  • 61. Setting the Command Button Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
  • 62. Setting the Employee Investment Scroll Bar Control Properties With Excel in Design mode, click the Employee Investment Scroll Bar control Click (Name) in the Properties window and then type scrEmployeeInvest as the name If necessary, change the LargeChange property to 100, the Max property to 1300, the Min property to 0, and the SmallChange property to 50 © OpenCastLabs Consulting. www.opencast-labs.com
  • 63. Setting the Employee Investment Scroll Bar Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
  • 64. Setting the Employer Match Scroll bar Control Properties With Excel in Design mode, click the Employer Match Scroll Bar control Click (Name) in the Properties window and then type scrEmployerMatch as the name Change the LargeChange property to 100, the Max property to 600, the Min property to 0, and the SmallChange property to 25 © OpenCastLabs Consulting. www.opencast-labs.com
  • 65. Setting the Employer Match Scroll bar Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
  • 66. Setting the Check Box Control Properties With Excel in Design mode, click the Check Box control Click (Name) in the Properties window and then type chkEmployerMatch as the name Click Alignment in the Properties window and then click 0 - fmAlignmentLeft Click Caption in the Properties window and then type Include Employer Match? as the caption Click SpecialEffect, click the box arrow in the Properties window, and then click 0 - fmButtonEffectFlat Click Value in the Properties window and then type True as the value Resize the Check Box control so the entire caption shows © OpenCastLabs Consulting. www.opencast-labs.com
  • 67. Setting the Check Box Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
  • 68. Setting Properties for the Annual Return and Years of Service Spin Button Controls With Excel in Design mode, click the Annual Return Spin Button control Click (Name) in the Properties window and then type spnAnnualReturn as the name If necessary, change the Max property to 2500, the Min property to 0, and the SmallChange property to 25 Click the Years of Service Spin Button control Click (Name) in the Properties window and then type spnYearsofService as the name Change the Max property to 45, the Min property to 1, and the SmallChange property to 1 © OpenCastLabs Consulting. www.opencast-labs.com
  • 69. Setting Properties for the Annual Return and Years of Service Spin Button Controls © OpenCastLabs Consulting. www.opencast-labs.com
  • 70. Setting the Variable Label Control Properties With Excel in Design mode, click the Label control to the left of the Annual Return Spin Button control Click (Name) in the Properties window and then type lblAnnualReturn as the name Click Caption in the Properties window and then type 5% as the caption Change the BorderStyle property to 1 - fmBorderStyleSingle Change the BackColor property to white Change the TextAlign property to 3 - fmTextAlignRight Resize the Label control © OpenCastLabs Consulting. www.opencast-labs.com
  • 71. Setting the Variable Label Control Properties Click the Label control to the left of the Years of Service Spin Button control Click (Name) in the Properties window and then type lblYearsofService as the name Click Caption in the Properties window and then type 10 as the caption Change the BorderStyle property to 1 - fmBorderStyleSingle Change the BackColor property to white Change the TextAlign property to 3 - fmTextAlignRight Resize the Label control Click the Close button on the right side of the Properties window title bar © OpenCastLabs Consulting. www.opencast-labs.com
  • 72. Setting the Variable Label Control Properties © OpenCastLabs Consulting. www.opencast-labs.com
  • 73. Resizing and Repositioning the Controls in the Personalization Center Click the Properties button on the Ribbon If necessary, drag the Properties window to the left side of the Excel window Click the Enter Name and Salary Command Button control Change its Top, Left, Height, and Width properties to those listed in Table 7–4 to display the Enter Name and Salary Command Button One at a time, select the controls in the Personalization Center and change their Top, Left, Height, and Width properties to those listed in Table 7–4 Close the Properties window and then deselect the Years of Service (1 to 45 years) label by clicking cell A1 Click the Save button on the Quick Access Toolbar to save the workbook using the file name, Caliber Steel3 © OpenCastLabs Consulting. www.opencast-labs.com
  • 74. Resizing and Repositioning the Controls in the Personalization Center © OpenCastLabs Consulting. www.opencast-labs.com
  • 75. Entering the Enter Name and Salary Button Procedure With Excel in Design mode, click the View Code button on the Ribbon Click the Object box arrow at the top of the window and then click CommandButton1 in the alphabetical list Click before the P in Private and then press the ENTER key. Enter the lines 1 through 9 in Table 7–5 Click the blank line between the Sub and End Sub statements. Enter lines 11 through 22 in Table 7-5 being sure to indent each line of code by three spaces for readability © OpenCastLabs Consulting. www.opencast-labs.com
  • 76. Entering the Enter Name and Salary Button Procedure © OpenCastLabs Consulting. www.opencast-labs.com
  • 77. Entering the Employee Investment Scroll Bar Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click scrEmployeeInvest Enter the VBA code shown in Table 7–6 © OpenCastLabs Consulting. www.opencast-labs.com
  • 78. Entering the Employee Investment Scroll Bar Procedure © OpenCastLabs Consulting. www.opencast-labs.com
  • 79. Entering the Employer Match Check Box Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click chkEmployerMatch Enter the VBA code shown in Table 7–7 © OpenCastLabs Consulting. www.opencast-labs.com
  • 80. Entering the Employer Match Check Box Procedure © OpenCastLabs Consulting. www.opencast-labs.com
  • 81. Entering the Employer Match Scroll Bar Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click scrEmployerMatch. Enter the VBA code shown in Table 7–8 © OpenCastLabs Consulting. www.opencast-labs.com
  • 82. Entering the Employer Match Scroll Bar Procedure © OpenCastLabs Consulting. www.opencast-labs.com
  • 83. Entering the Annual Return Spin Button Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click spnAnnualReturn Enter the VBA code shown in Table 7–9 © OpenCastLabs Consulting. www.opencast-labs.com
  • 84. Entering the Annual Return Spin Button Procedure © OpenCastLabs Consulting. www.opencast-labs.com
  • 85. Entering the Years of Service Spin Button Procedure With the Visual Basic Editor active, click the Object box arrow at the top of the window and then click spnYearsofService Enter the VBA code shown in Table 7–10 © OpenCastLabs Consulting. www.opencast-labs.com
  • 86. Entering the Years of Service Spin Button Procedure © OpenCastLabs Consulting. www.opencast-labs.com
  • 87. Closing the Visual basic Editor, Protecting the Worksheet, and Saving the Workbook Click the Close button on the right side of the Visual Basic Editor title bar When the Excel window is visible, click the Design Mode button on the Ribbon to exit Design mode Click the Review tab on the Ribbon and then click the Protect Sheet button on the Ribbon When Excel displays the Protect Sheet dialog box, type caliber in the ‘Password to unprotect sheet’ text box. Verify the password when prompted and then click the OK button Click the Save button on the Quick Access Toolbar to save the workbook using the file name, Caliber Steel3 © OpenCastLabs Consulting. www.opencast-labs.com
  • 88. Testing the Controls in the Personalization Center Click the Enter Name and Salary button in the Personalization Center When Excel displays the Enter dialog box with the prompt message, Employee Name?, type Gina Moira as the employee name When Excel displays the Enter dialog box with the prompt message, Annual Salary?, type the negative number –54500 as the annual salary When Excel displays the Enter dialog box with the prompt message, Annual salary must be > zero, type 54500 as the annual salary © OpenCastLabs Consulting. www.opencast-labs.com
  • 89. Testing the Controls in the Personalization Center Use the Employee Investment scroll bar to change the value in cell D7 to 6% Click the Include Employer Match check box if it does not have a check mark Use the Employer Match scroll bar to change the value in cell D8 to 4% Click the Annual Return spin button arrows to change the value in cell D9 to 8.5% Click the Years of Service spin button arrows to change the value in cell D10 to 35 © OpenCastLabs Consulting. www.opencast-labs.com
  • 90. Resetting the Quick Access Toolbar and Ribbon and Quitting Excel Right-click anywhere on the Quick Access Toolbar and then click Customize Quick Access Toolbar on the shortcut menu When the Excel Options dialog box appears, click the Reset button and then click the OK button in the Reset Customizations dialog box. Click the OK button to close the Excel Options dialog box Click the Office Button and then click the Excel Options button on the Office Button menu Click the ‘Show Developer tab in the Ribbon’ check box to remove the check mark and then click the OK button to close the Excel Options dialog box Click the Close button on the right side of the title bar If the Microsoft Office Excel dialog box appears, click the No button © OpenCastLabs Consulting. www.opencast-labs.com
  • 91. Adding a Digital Signature to a Workbook Click the Insert tab on the Ribbon and then click the Signature Line button on the Ribbon. If the Microsoft Office Excel dialog box appears, click the OK button When the Signature Setup dialog box appears, type your name in the Suggested signer text box and then click the OK button When Excel adds the signature box to the workbook, right-click anywhere in the signature box and then click Sign on the shortcut menu When the Sign dialog box appears, type your name in the signature box or click the Select Image link to select a file that contains an image of your signature Click the OK button to digitally sign the document © OpenCastLabs Consulting. www.opencast-labs.com
  • 92. Reviewing a Digital Signature on a Workbook Click the Office Button and then click Prepare on the Office Button menu Click View Signature on the Prepare submenu Select a name from the Valid signature list in the signature pane and then click the button arrow next to the name. When the shortcut menu appears, click Signature Details When you are finished reviewing the certificate, click the OK button in the Signature Details dialog box © OpenCastLabs Consulting. www.opencast-labs.com
  • 93. Summary Use passwords to assign protected and unprotected status to a worksheet Use the macro recorder to create a macro Execute a macro and view and print code for a macro Understand Visual Basic for Applications (VBA) code and explain event-driven programs Customize the Quick Access Toolbar by adding a button © OpenCastLabs Consulting. www.opencast-labs.com
  • 94. Summary Add controls, such as command buttons, scroll bars, check boxes, and spin buttons to a worksheet Assign properties to controls Use VBA to write a procedure to automate data entry into a worksheet Understand Do-While and If-Then-Else statements Review a digital signature on a workbook © OpenCastLabs Consulting. www.opencast-labs.com
  • 95. Excel Chapter 7 Complete