Recipe1.2.Entering Data

Recipe 1.2. Entering Data


You've familiarized yourself with Excel's layout and now you're ready to enter data into a spreadsheet but don't know how.


Select a cell in the spreadsheet and starting typing. Press Enter when done.


When you select a cell in a spreadsheet, it becomes highlighted with a thick black border, as shown in Figure 1-3. In that figure the cell in row 3 and column B is the selected cell. Notice the row and column headings of the currently selected cell are highlighted. Once a cell is selected in this manner, you can simply start typing on the keyboard to insert text in the cell. Press Enter when you are finished and notice that the cell below the one within which you entered text is now automatically selected. This allows you to type and enter text in a column of cells rapidly, without having to select the next cell using the mouse.

Figure 1-3. Excel Help task pane

Upon entering text, you can also press the Tab key to commit your entry and move the cell selection to the next cell to the right. Alternatively, you can use the arrow keys on your keyboard to commit an entry and move to any cell adjacent to the cell within which you've entered text. Of course you can always use the mouse to click on a cell, selecting it for input; however, doing this may slow you down if you are trying to enter text in a contiguous group of cells, since you'll have to remove your hands from the keyboard very often.

You can also enter text into a cell using the formula bar (located just above the spreadsheet grid and just below the toolbars), as shown in Figure 1-4. The formula bar has an fx icon, adjacent to a long white rectangular area.

Click anywhere in the white rectangular area of the formula bar to give it the input focus and then start typing. Your text will appear in both the formula bar and the currently selected cell. To commit the entry, press the Enter key or press the green checkmark icon on the formula bar. To cancel your entry, press the red x icon or press the Esc key on your keyboard.

Figure 1-4. Using the formula bar

Let's say you want to make changes to some text already entered in a cell. To make changes to a cell entry, select the cell with the mouse or use the arrow keys to navigate the grid and then press the F2 shortcut key to put the cell in edit mode, allowing you to edit the contents of the cell. Alternatively, double-clicking on a cell will automatically select it and put it in edit mode. Finally, you can always select a cell and simply start typing and press Enter to completely overwrite the contents of the cell.

Recipe 1.3. Setting Cell Data Types


You've learned how to enter text from the previous recipe, but now you want to enter data other than text (e.g., numbers, dates, and currency).


Enter the data just as you would text and let Excel automatically figure out its type, or use the Format images/U2192.jpg border=0> Cells... menu to open a dialog box allowing you to manually format the data type for a cell.


In the previous recipe, I had you simply enter text in cells. Whether you entered a word or a number, Excel automatically figured out what type of data you entered. In general, input starting with letters is automatically interpreted as text, and input starting with numbers is automatically interpreted as numeric. There are some special cases worth noting here. Preceding any string of charactersnumbers or letterswith the ' symbol forces Excel to interpret the data as text. Preceding a string of numbers with the $ symbol forces Excel to interpret the data as currency. Using E (or e) while entering a number in scientific notation forces Excel to interpret the string as a number in scientific notation. Entering numbers with dashes between them will cause Excel to interpret the number as a date. I encourage you to try entering various types of data like those I describe here to see how Excel handles the data. In some cases you'll notice that Excel will reformat your data a little. For example, if you type 1.2345e3 in a cell, it will appear as 1.23E+3 in the cell and 1234.56 in the formula bar (when the cell is selected).

In general, Excel is pretty smart about interpreting the data type you intend; however, sometimes it does need a little help. Also, sometimes you may want to change the format of the data to give it an appearance other than the default appearance assigned to it by Excel. In these cases you can manually specify the type and format of data contained in cells by accessing the Format Cells dialog box . You can do so by selecting Format images/U2192.jpg border=0> Cells... from the menu or by using the shortcut key combination, Ctrl-1.

Figure 1-5 shows the Format Cells dialog box. Notice here I had a cell selected that contained the entry 1.2345e3, which appears in the Sample area of the dialog box. This allows you to preview the results while making format changes.

I find that one of the most common uses of formatting tasks is specifying the number of decimal places to show for numbers. You can specify the number of decimal places to show by entering a value in the "Decimal places" field. Changing this setting is a format change only; it does not change the data itself. For example, if you enter 123.45678 in a cell and set the number of decimal places to 3, the cell will show 123.457 but the actual number is still stored as 123.45678, as can be seen in the formula bar when the cell is selected.

You can also select one of the categories shown in the Format Cells dialog box to set the type of data. If you click each category in the list, a short description and other formatting options will appear in the Format Cells dialog box. For example, if you select the Number category, the Format Cells dialog box will appear (see Figure 1-6).

The new formatting options appear on the right side of the dialog box, just under the "Decimal places" setting.

Format changes affect the currently selected cell and remain in effect until you change the format. If you set a cell to display Currency and then enter a new value in that cell, it will also be interpreted as currency.

Figure 1-5. Format cells dialog box

Figure 1-6. Format Cells with the Number category selected

You need not always use the Format Cells dialog box to change cell formatting. Some of these formatting operations have been assigned to toolbar buttons for convenience. Take a look at Figure 1-7 and notice the toolbar buttons that I highlighted. These specific buttons allow you to change some cell format properties with the click of a button.

Figure 1-7. Cell format toolbar

The $ button changes the cell format to currency while the % button changes the cell format to percentage; e.g., if you enter 0.38, it will show up as 38%. The two other highlighted buttons respectively increase and decrease the number of decimal places to show.

I should also point out that formatting changes take effect for all of the cells currently selected. So far, I've only discussed selecting a single cell; however, there are times when you may want to make changes to multiple cells all at one time. The next recipe explains how to select more than one cell at a time.

See Also

I find the Number, Percentage, and Scientific format categories more than adequate for most scientific and engineering computing tasks; however, there may be occasions when you want to set your own specific data format for a unique application. In this case, you can actually specify your own format template in the Format Cells dialog box by setting up format codes using the Custom format category. I won't go into the details here since it's fairly well documented in Excel's online help. To learn more, open the Excel Help task pane and do a search using the key phrase "Custom Formatting." In your search results, look for the topics entitled "Create or delete a custom number format" and "Number format code."