PMI Online Education Get Data from External Sources Activities Microcomputer Applications
Table of Contents Objective 1: Import Data into Excel... 3 Importing Data from a Word Table... 3 Importing Data from a TXT File... 4 Importing Data from Access... 5 Importing Data from a Comma Delimited FIle... 5 Objective 2: Reorganize Data from External Sources... 6 Converting Text into Columns... 6 Removing Spaces Using the Trim Function... 7 Consolidating Data... 8 Highlighting Duplicate Values Using Conditional Formatting... 10 Removing Duplicate Records... 11 Creating a Table and Printing Results... 12 Unlocking Cells for Data Entry and Protecting a Worksheet... 13 Hiding Formulas in the Worksheet... 14 Setting a Print Area... 14 Saving the Order Form as a Template... 15 Get Data from External Sources 2
Objective 1: Import Data into Excel Importing Data from a Word Table Paste Special Dialog Box Start Excel and open a new blank workbook. Save the new file as Manipulate_Data_Firstname_Lastname. Start Word and open the provided file named Import_Word. Notice the table format used and its similarities to Excel. In Word, click the Select Table button to highlight the entire table. Alternatively, from the Layout tab, in the Table group, click the Select button and choose Select Table. Copy the table and exit Word. The copied information is stored on the Office Clipboard. Return to cell A5 in the Excel worksheet. On the Home tab, in the Clipboard group, click the Paste button arrow. Select Paste Special from the list. From the Paste Special dialog box, in the As section, select Text and click OK. Select columns A:K and AutoFit all columns by double-clicking one of the column heading boundaries. Rename Sheet1 as Private_Homes and save the workbook. Get Data from External Sources 3
Importing Data from a TXT File A text file contains plain ASCII text. Text files are not formatted, which reduces the file size. They are commonly used for log files, readme files, and source data. Text files can be opened with basic text editors or word processing programs. These files usually have a.txt extension and never contain graphics. Text Import Wizard Dialog Box Rename Sheet2 as Mullin_Listings. Click the Data tab and then in the Get External Data group, click the From Text button. From the Import Text File dialog box, navigate to the provided data file Import_TXT and click Import. Follow the steps in the Text Import Wizard dialog box. A delimited file uses a character such as a comma, a colon and so on. A fixed field width means that each field has exactly same number of places. For example, First Name may have a size of 25 and no matter if the name is Joe, MaryAnn or Hubert, the first name field always has 25 spaces. Select Delimited and click Next. Select the Tab delimiter and clear any other choices. Make sure a check is in the Treat consecutive delimiters as one check box. Observe changes that occur in the Data Preview box, then click Next. The last step is used to set column formatting and choose what information to import. Click Finish. In the Import Data dialog box, specify cell A1 and click OK. To convert the vertical list to a horizontal one, copy the range A1:B11. Click cell D1 and, from the Home tab, in the Clipboard group, click the Paste button arrow. Click Transpose. Copy the range B13:B23 and right-click cell D3. Select Paste Special from the shortcut menu. Place a check in the Transpose check box and click OK. Since the field names have already been transposed, there is no need to copy the data in column A again. Repeat this process for the last two records using either transpose method, then delete columns A:C. AutoFit the columns containing data and save the workbook. Get Data from External Sources 4
Importing Data from Access Selecting Closed Listings Rename the Sheet3 tab as Homes_Sold Click the Data tab and in the Get External Data group, click the From Access button, then locate and open the provided Import_Access file. In the Select Table dialog box, select the Closed Listings table and click OK. In the Import Data dialog box, make sure the Table button and the Existing Worksheet buttons are selected, and that the cell address is cell A1, then click OK. On the Design tab, in the Tools group, click the Convert to Range button and click OK for the warning message to break the link to the Access database. Remove the banded lines from the data by selecting the range A1:L25. Then on the Home tab, in the Styles group, click the Cell Styles button. Click Normal. Save the workbook. Importing Data from a Comma Delimited File Selecting Comma for Delimiters Click the Insert Worksheet button to insert a new worksheet to the right of the Homes_Sold sheet tab. Name the new sheet Homes_Sold2 Start Word and open the file Import_CSV. If the File Conversion dialog box displays, make sure the Windows (Default) choice is selected under Text encoding and click OK. With the Show/Hide button activated, point out the field names in the first two lines and show how data is separated by commas and records are separated by paragraph marks. Close the file and exit Word. Return to the Homes_Sold2 worksheet. Click the Data tab, then in the Get External Data group, click the From Text button. When the Import Text File dialog box displays, navigate to the provided file Import_CSV and click Import to open the file. In the Text Import Wizard dialog box, select the Delimited option and click Next. Select the Comma check box for Delimiters, clear all other check marks, and click Next. In the Data Preview screen, scroll through the fields displayed. Click the Buyer column to select it. In the Column data format section, select Do not import column (skip). Note that the heading title has changed from General to Skip Column. Click Finish to complete the import process. The Import Data dialog box should import the data to cell A1 in the existing worksheet, click OK. Save the workbook. Get Data from External Sources 5
Objective 2: Reorganize Data from External Sources Converting Text into Columns Text to Columns Description It is impossible to sort the Seller field by last name the way it is currently set up. Click cell B7 and observe the number of spaces used to separate names. Select columns C:E and insert three new columns. Convert the text in the range B2:B18 by selecting the range and then on the Data tab, in the Data Tools group, click the Text to Columns button. In the Convert Text to Columns Wizard dialog box, select Delimited and click Next. Select the Space check box and clear any other selections, then click Finish. Observe how some data has been expanded to adjacent cells. Manually edit the records that originally had multiple names (cells B2, B7, B11, and B18) to include the ampersand and the other first name. For example, double-click to the right of the name Alan in cell B2, add a space and type & Deni Delete column D. Replace the contents of cells C2, C7, C11, and C18 by dragging and dropping the last names found in the cells in column D. Click OK to replace the destination cell data, then delete column D. Repeat this process for the cells in column B on the Private_Homes tab by inserting two columns and converting text to columns. Notice that row 23 and row 29 each had multiple spaces and required three columns to expand names. Combine names as appropriate. Rename the column headings in cells B5 and C5 to Owner s First Name and Owner s Last Name, replacing the original field name Owner. Delete column D and save the workbook. In Sheet2, type the following information into the designated cells: o A1: Main Street Realty o A2: Sales Summary by City and Property Type o A3: Through June 30, 2009 Format cells A1, A2, and A3 with 14 point font and Italics, then Merge & Center each cell over columns A:O. Rename the Sheet2 tab Summary and save the workbook. Get Data from External Sources 6
Removing Spaces Using the Trim Function When importing text to Excel, extra spaces often are also imported. The TRIM function removes spaces in text, except for one between words. You may also find it useful to remove spaces in a formula with the Trim function so the function works properly. Screen Tip for the Trim Function Click the Mullin_Listings tab and observe the leading spaces in cells C3 and C4, as well as in some cells in columns D and K. In cell C7, type =Trim and observe the ScreenTip that displays. Complete the formula by adding (c2) and pressing Enter, then observe the results. Copy the formula from cell C7 through the range C8:C10. Then, copy the formula to the range D7:D10. Copy the range C7:D10 and click cell C2. On the Home tab, in the Clipboard group, click the Paste button arrow and select Paste Values. Demonstrate that the Paste Values option pastes the revised data, but not the formulas in the cells, and note that pasting the formulas would not have produced the desired results. Delete the range C7:D10. Delete columns J and K containing the Buyer and Sales Agent information. Insert a new column to the right of column B. Use the Convert Text to Columns feature to separate the sellers first and last names, using the Space option for the delimiter. Save the workbook. Get Data from External Sources 7
Consolidating Data Side by Side View Click the Private_Homes tab and select cell A1. On the View tab, in the Window group, click the New Window button to create a copy of the workbook. Click the View Side by Side button to tile the two workbooks vertically. Note the addition of the numbers 1 and 2 to the end of the workbook file names and that the Synchronous Scrolling button is now activated. In the top window of the workbook, scroll down to make row 5 the top row and click cell A6. In the Window group, click the Freeze Panes button and pick Freeze Panes from the list that displays. Scroll down to display row 31. Observe that both worksheets scroll simultaneously and there are now two workbook buttons on the task bar. In the bottom worksheet, click the Mullin_Listings tab twice to make it active and click cell A1. In the Window group, click the Synchronous Scrolling button to deactivate it. In the Mullin_Listings sheet, cut the range F1:G5 and paste the cells into cell K1 by right-clicking and selecting Insert Cut Cells. AutoFit columns I and J. Note that the data in the first 8 columns of the Mullin_Listings tab now match the columns in the Private_Homes tab, although the column headings may be slightly different. In the Mullin_Listings sheet, copy the range A2:H5. Click the Private_Homes sheet, and paste the data in cell A31. In the Private_Homes sheet, right-click column K and select Clear Contents to delete the data but leave the column. Right-click column K and select Insert to add another column. In cells K5 and L5, add the titles Sales Price and Closing Date Display rows 31:34. In the Mullin_Listings sheet, select the range I2:J5. Copy and paste this information to cell K31 on the Private_Homes sheet. AutoFit rows K and L. Return to the lower worksheet and click the Homes_Sold tab twice to activate it. Compare the fields in this sheet with those in the Private_Homes sheet above. There are fields that only appear in one worksheet such as the ID and El School fields. In the Homes_Sold sheet, delete column A (ID) and column C (El School). Copy the range A2:J25 and paste it into the Private_Homes sheet in cell D35. Note that the dates have converted to a general number format that will be addressed later. Return to the lower worksheet and activate the Homes_Sold2 sheet. Click cell A1 and compare the field headings between the two worksheets. Notice Get Data from External Sources 8
List of Available Windows that Homes_Sold2 includes fields for Sales Price and Closing Date, but not List Price and List Date. Copy columns F and G. Insert the copied cells in column K. The Sales Agent data moves to column M. Drag and drop the date in the range H1:J18 into columns F:H. Click OK to replace the destination cell data. Copy the range A2:M18 from the Homes_Sold2 sheet and paste it into cell A59 of the Private_Homes sheet. On the View tab, in the Window group, click the View Side by Side button to return to the single worksheet view. Note the second workbook button that remains on the task bar. In the Window group, click the Switch Windows button to display the list of available windows and note there are two choices with a check mark indicating the file that is the active window. Click the unchecked choice to select it and notice the selected cells that appear. Press Esc and click the Private_Homes tab. Note the data that has been consolidated on both sheets. Close this second workbook and note that you are not asked if you wish to save it. The remaining workbook title no longer displays a number at the end. AutoFit all of the columns in the Private_Homes sheet and save the workbook. Get Data from External Sources 9
Duplicate Street Addresses Highlighting Duplicate Values Using Conditional Formatting Press Ctrl+Home to return to the top of the Private_Homes sheet. On the View tab, in the Window group, click the Freeze Panes button and select Unfreeze Panes. Select the cells containing the addresses in column D. Click the Home tab and in the Styles group, click the Conditional Formatting button. Point to Highlight Cells Rules and select Duplicate Values. Click OK to select the default value of Light Red Fill with Dark Red Text. Scroll through the list to display the formatted duplicate cells. Deselect the column by clicking cell D5. On the Home tab, in the Editing group, click the Sort & Filter button and sort the list alphabetically. Scroll through the list and note that in rows 29 and 30, although the address is the same, the rest of the data is not. Examine all information in a record to ensure the data is actually a duplicate. Note also that some duplicate records may have data in some areas but not others. Get Data from External Sources 10
Removing Duplicate Records Remove Duplicates Dialog Box Apply the Comma style with 0 decimals to the range K6:K75. With the range still selected, use the Format Painter to apply this format to the range of cells in the List Price column by clicking cell I6. Apply the Short Date format to the range L6:L75. Use the Format Painter to format the range of cells in column J by clicking cell J6. Click cell D5. On the Data tab, in the Data Tools group, click the Remove Duplicates button to remove duplicate entries. In the Remove Duplicates dialog box, click the Unselect All button. If necessary, check the My Data Has Headers box. Select the following fields: Address, City, Sales Price. Make sure there is a check mark in the My data has headers box and click OK. A message displays indicating the number of duplicates that have been removed, click OK. Because of the additional fields being checked, not all duplicates indicated by the conditional formatting were removed. Observe that most of the remaining duplicates have a list price and list date or a sale price and closing date in one record, but not in the other. Consolidate this information so that the list price and list date and sale price and closing date are in the same record for each of these duplicates. Return to cell D5 and repeat the Remove Duplicates process, clearing all choices except Address and City, then click OK. A message appears indicating additional duplicate values were removed. Click OK to continue. Two duplicates remain displaying the conditional formatting the values in rows 22 and 23. The homes listed on Fire Heights Dr have the same street address but all other information is different. Get Data from External Sources 11
The Table Styles Gallery Filter Symbol Creating a Table and Printing Results Insert the following text in the designated cells: o A1: Main Street Realty o A2: Private Homes Sales Report o A3: Through June 30, 2009 Format the range A1:A3 as Bold, Italic, 14 point font. Click cell A5. On the Insert tab, in the Tables group, click the Table button. Confirm that the Create Table dialog box has selected the range A5:M62. If necessary, check the box next to My Data Has Headers and click OK. On the Design tab, in the Table Styles group, click the More button to change the style of the table. From the Table Styles gallery, select Table Style Medium 11 from the Medium section. In cell I5, click the List Price arrow and uncheck the box next to Blanks, then click OK. Repeat this process to remove the blank cells from the Sales Price column. Observe that the arrow in each cell has changed to the filter symbol. In the Table Styles Options group, click the Total Row button. Observe that a new row has been added to the worksheet. Click cell I63 for the List Price total cell and click the arrow, then click Average. Repeat this process for the Sales Price cell, K63. Format cells I63 and K63 to use the Accounting Number Format and no decimals. Get Data from External Sources 12