Deidre uses an Excel worksheet to store latitude and longitude values. These values are entered in cells in the format 26:05:35, which Excel interprets as hours, minutes, and seconds. Internally, Excel converts the entry into an internal date value. This means that the value is stored internally as the serial number 1.08721064814815, but is displayed, automatically, in the elapsed time format.
Deidre is running into a problem when she tries to use the data in the worksheet with a different program that needs the latitude and longitudes values in text format. In other words, she needs them in a text file in the format 26:05:35, not in some other date/time representation that may be picked by Excel.
The first thing to try is to select all the cells that contain latitudes and longitudes, and make sure they are formatted properly. Follow these steps:
- Select all the cells.
- Press Ctrl+Shift+F. Excel displays the Format Cells dialog box.
- Make sure the Number tab is displayed.
- Make sure that Time is selected in the Category list. (See Figure 1.)
- Make sure that 37:30:55 is selected in the Type list. (This is the elapsed time format.)
- Click on OK.
Figure 1. The Number tab of the Format Cells dialog box.
Now you should be able to save the file in text format, and the latitudes and longitudes will look as expected:
- Save your workbook in regular Excel format.
- Press F12. Excel displays the Save As dialog box.
- Using the Save As Type drop-down list, indicate that you want to save the worksheet as Text (Tab Delimited).
- Use the other controls in the dialog box to specify a location and file name for the text file.
- Click on Save. Excel reminds you that you will lose formatting and some features by saving the file in text format. That’s OK; it is the reason you saved the file in Excel format in step 1.
When done, you should be able to open the Excel-created text file and see that it contains the latitudes and longitudes in the format wanted. If it doesn’t (for some bizarre reason), then you should try the following:
- Insert an empty column to the right of your latitudes or longitudes. (In this example, I assume that the latitudes or longitudes are in column A, and you insert a blank column at B.)
- In the cell to the right of the first latitude or longitude (assume that value is in A3, so you would choose B3), enter the following formula:
- Copy the formula down to all the other cells that need converting.
- Select all the formulaic cells in column B.
- Press Ctrl+C to copy them all to the Clipboard.
- Select cell A3.
- Display the Home tab of the ribbon.
- Click the down-arrow at the bottom of the Paste tool and then choose Paste Special. Excel displays the Paste Special dialog box. (See Figure 2.)
- Make sure the Values option is selected.
- Click on OK. Excel pastes just the values-the text values-into the original cells.
- Delete column B.
Figure 2. The Paste Special dialog box.
The formula used in step 2 probably bears some explanation. It takes the value in A3 (the date serial value) and formats it as elapsed time, but as text. This is the format in which you ultimately want the values. You should now be able to save your worksheet as a text file (use the steps provided earlier in this tip), and the latitudes and longitudes should be formatted as expected.