Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science & Engineering 2111 Lecture 9 Data Validation, Worksheet Protection, and Macros 1CSE 2111 9-Data Validation and Macros.

Similar presentations


Presentation on theme: "Computer Science & Engineering 2111 Lecture 9 Data Validation, Worksheet Protection, and Macros 1CSE 2111 9-Data Validation and Macros."— Presentation transcript:

1 Computer Science & Engineering 2111 Lecture 9 Data Validation, Worksheet Protection, and Macros 1CSE 2111 9-Data Validation and Macros

2 Data Validation Controls the type of data or the values input in a cell Reduces input errors Multiple criterion can be applied to a cell CSE 2111 9-Data Validation and Macros2 Display a message dialog boxRestrict input to a whole number within limits Restrict input to values in a drop down listRestrict input to a decimal number within limits Restrict input to a certain time frame. (either date, time, or both) Restrict text to a specified length Calculate what is allowed based on the value in another cell Use a formula to calculate what is valid

3 Macro A series of commands and functions that are stored in a Microsoft Visual Basic module Automates your keystrokes and actions in Excel Use these when you complete the same tasks repetitively When you create a macro VBA program code is automatically generated CSE 2111 9-Data Validation and Macros3

4 Macro Example Scenario You work for a company that employs people to make customer satisfaction calls for various companies. Your department provides services for all the major auto makers in the U.S. Each employee is assigned a state and it is their job to call each household and conduct a brief survey. You receive a weekly list of customers from each auto company and it is your job to separate the list by state and distribute the list to your employees. Your manager would like the customers stored in an Excel file with each state having its own worksheet. CSE 2111 9-Data Validation and Macros4

5 File Sent from Vendor Comma Delimited File, meaning each piece of information is separated by a comma. (Created in Notepad or another text editor.) Information can be separated by other characters such as a colon, or tab. Information can be sent in different formats such as.csv or xml files. 5CSE 2111 9-Data Validation and Macros

6 Create your Template 1.Create an Excel Workbook named Customers. 2.Create tabs with the names of the States you need. 3.Input information that will not change 6CSE 2111 9-Data Validation and Macros 4.Copy the worksheet created to all the tabs and change the state name (Follow the slides to complete steps 4-6)

7 CSE 2111 9-Data Validation and Macros7 4.Create data validation rules for your spreadsheet

8 Break Down into Separate Macros 1.Macro Name: UnprotectWorksheets 2.Macro Name: ImportFile 1.Delete contents from every worksheet 2.Import information 3.Macro Name: SeparateStates 1.Concatenate phone number 2.Filter 3.Copy/Paste 4.Macro Name: ProtectWorksheets Note: Always create a backup first CSE 2111 9-Data Validation and Macros8

9 ProtectWorksheet Macro CSE 2111 9-Data Validation and Macros9

10 10

11 ImportFile Macro CSE 2111 9-Data Validation and Macros11

12 SeparateStates Macro CSE 2111 9-Data Validation and Macros12

13 CSE 2111 9-Data Validation and Macros13

14 Example of VBA Program Code generated from recording macro Sub ImportFile() Range("A4:H56").Select Selection.QueryTable.Delete Selection.ClearContents Range("A4").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;L:\CSE2111\Autumn 2013\CSE 2111 Slides AU 2013\Lecture 9-Data Validation and Macros\Macro Test\Customers.txt" _ CSE 2111 9-Data Validation and Macros14 Step through a macro

15 Assigning Macro to the Quick Access Toolbar 1.File  Options  Quick Access Toolbar CSE 2111 9-Data Validation and Macros15

16 CSE 2111 9-Data Validation and Macros16


Download ppt "Computer Science & Engineering 2111 Lecture 9 Data Validation, Worksheet Protection, and Macros 1CSE 2111 9-Data Validation and Macros."

Similar presentations


Ads by Google