Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Data Management Resources in Excel 205

FIGURE 10.9

2. Sort the data by category to ensure that the line items are grouped together by that
column. This is accomplished using the DATA/SORT & FILTER/Sort menu item.
Make sure that My data has headers is selected and pick the Category column
name for the Sort by eld.
3. Engage the subtotaling facility via the DATA/OUTLINE/Subtotal menu choice,
and the dialog box in Figure 10.11 will appear.
4. Change the At each change in: drop-down value to be Category, and check the box
for Number on Hand in the Add Subtotal to: window. Both Number on Hand and
Ext. Cost should be checked for subtotals.
5. Click OK to see the result in Figure 10.12. Notice that Excel has inserted subtotal
lines for each category and has provided a subtotal of items on hand in that cat-
egory as well as the values of those items. In addition, a Grand Total is provided at
the bottom of the sheet.
6. Note that there are three columns numbered 1, 2, and 3 to the left of the row
numbers of the worksheet. These designate the levels of information in the data
set. Clicking on the number three shows all details of the data set. Clicking on the
number two will show just the subtotals and the Grand Total, and clicking on the
number one will show only the Grand Total. Figure 10.13 shows the result of click-
ing on the number two.
206 What Every Engineer Should Know About Excel

FIGURE 10.10

FIGURE 10.11
Data Management Resources in Excel 207

FIGURE 10.12

FIGURE 10.13

10.4 Useful Data Functions in Excel


Through many years of using Excel for data processing and manipulation, numerous Text
and Lookup/Reference Excel functions show their use and versatility on nearly a daily
basis. These very useful functions are shown in Table 10.1. Refer to the Excel Help function
(press F1 from within Excel) for more information on each function.
208 What Every Engineer Should Know About Excel

TABLE 10.1
Useful Data Processing and Manipulation Functions
Function Description
CONCATENATE(), Used to create one string of characters from several individual strings. CONCAT() is
CONCAT() only available in Of ce 365. Resultant string is limited to 32,767 characters
FIND() Used to nd a string within a string and return the position at which that substring
begins. This function is case-sensitive
LEFT() Used to grab and return the leftmost characters of a string value. The number of
characters is speci ed as an argument to the function
LEN() Used to return the length of a string value
LOWER() Used to convert a value to all lowercase characters
MID() Used to return the middle of a string value given a starting and ending character
position
REPLACE() Used to replace one string with another within a target string
RIGHT() Used to grab and return the rightmost characters of a string value. The number of
characters is speci ed as an argument to the function
SEARCH() Used to nd a string within a string and return the position at which that substring
begins. Unlike the FIND() function, this function is NOT case-sensitive
TEXT() Used to convert a numeric value to a text value
TRIM() Used to trim extraneous spaces from a string value except for single spaces between
words
UPPER() Used to convert a value to all uppercase characters
VALUE() Used to convert a string of numbers from a text value to a numeric value
VLOOKUP() Used to look up a value in a row of data given a matching value in the rst element of
the row. Similar to HLOOKUP() except that HLOOKUP() operates on columns rather
than rows

Example 10.1: String Manipulation Using Several Functions in Table 10.1


Consider the data set in Figure 10.14. Note that there are several holes in the data set,
which the functions in Table 10.1 can easily help us ll. For example,

– The ID eld is intended to be the rst three letters of the last name with the
index appended to it.
– The Full Name is intended to be the piecing together of the First Name, Middle
Initial, and Last Name with appropriate spacing.
– The Simple Zip is intended to be the rst ve characters of the Zip+4 eld.
– The Plus 4 is intended to be the last four characters of the Zip+4 eld.
– The Area Code is intended to be the rst three characters of the Telephone eld.

FIGURE 10.14
Data Management Resources in Excel 209

FIGURE 10.15

FIGURE 10.16

The worksheet in Figure 10.14 is put into formula display mode, which you will recall
from previous chapters is accomplished via the CTRL+` key sequence. Using several
of the functions from Table 10.1, Figure 10.15 shows how these functions can be used
in the open columns of data to accomplish the intentions noted above. Figure 10.16
shows the nal results by switching back to displaying values from formulas using the
CTRL+` toggle key sequence.
The reader is left to add a column for cleaning up the middle initials, making them
uppercase, and copying and pasting them back into the proper place. Observe how the
Full Name changes when this cleanup is complete.

10.5 Connecting Excel to External Data


When a data source is available for analysis outside of Excel, it is convenient to be able to
reference that data source without having to type the data into a worksheet or rebuild the
data otherwise. An example of an external data source might be an MS Access database
to which a data logging tool has recorded experimental data. Similarly, a Central Plant
management system may store numerous data readings on temperatures and water ow
throughout the system, which warrant analysis. Excel provides quite a bit of exibility in
connecting to such data sources and accessing the data for analysis, charting, or process-
ing purposes.
210 What Every Engineer Should Know About Excel

10.5.1 General Concepts


Excel has the capability of connecting to data outside of the current workbook and main-
taining a reference that such data are external and may need to be refreshed periodically.
The external data can be in many forms: an Excel workbook, an MS Access database, an
MS SQL Server database, a MySQL database, or one of many others.
The idea is to con gure an Excel worksheet to look outside itself for data and show the
data in the current worksheet for analysis or manipulation purposes. In the discussions that
follow, it is assumed that the reader has a basic understanding of databases and tables in the
context of typical database systems. For an in-depth understanding of databases, the reader is
encouraged to explore any number of other sources including Microsoft.com and mysql.com.

10.5.2 Connecting to MS Access


Consider a building security system that is logging badge swipes of employee badges as
employees enter and exit the doors of their employer’s building. Let’s say that the logging
system has extremely poor reporting capabilities and the company’s executive manage-
ment would like a report of the last 100 people to enter the facility. The logging system
stores its data in an MS Access database.
Say that the name of the MS Access database is SecuritySystem.accdb and the table in the
database that is home to the badge swipes is named BadgeSwipes. To con gure MS Excel
to connect to this sample database, perform the following steps:

1. Open a new Excel workbook to Sheet1.


2. Click on DATA/GET EXTERNAL DATA/From MS Access.
3. Locate the le system path to the MS Access database le SecuritySystem.accdb,
highlight that lename, and click Open.

FIGURE 10.17

You might also like