Monday, April 9, 2012

Processing List of Numbers into Excel

Suppose we have the a list of numbers separated by comma and space that we need to get into Excel sorted. What's the fastest way to do this? If the data is small, it might be faster to type each. But as the data gets large, that will be very inefficient. Preserving the accuracy will also be more difficult as the number of entries increase. So let's begin with a data like this in a string of text:
84, 49, 61, 40, 83, 67, 45, 66, 70, 69, 80, 58, 68, 60, 67, 72, 73, 70, 57, 63, 70, 78, 52, 67, 53, 67, 75, 61, 70, 81, 76, 79, 75, 76, 58, 31
Here are the steps to generated a sorted list out of those numbers into a column in Excel:
  1. We want to get rid of the commas. Copy the string of text into Microsoft Word. Hit Control + F to bring Find and Replace menu. Click the Replace tab. We want to enter the comma "," under 'Find What' and nothing "" under 'Replace With'. Hit 'Replace All'.  The string should now be cleansed of commas.
  2. With no commas now, it's ready to be used by Excel. Copy this cleansed text and pasted into an Excel cell. Let's call this cell A1. The entire cleansed string should be in A1.
  3. We want to separate each number into its own cell. First highlight A1. At the 'Data' tab at the top of the Excel window, click on 'Text to Columns'. Choose the 'Delimited' option and hit 'Next'. Under the option of 'Delimiters', check the 'Space' box, and hit 'Finish'. Now each number will occupy its own cell.
  4. The data are all on the same row. However most times, we want the data on the same column. To convert, first highlight all of the values on A row. Control C to copy. Now highlight cell A2. Right-click the mouse and choose 'Paste Special'. At the bottom of the menu, check the 'Transpose' box and click 'OK'. The values now will be pasted in a column.
  5. Delete the top row by first clicking on the '1' row numbering. The entire top row should now be highlighted. Right-click and choose 'Delete'. We already have the data in the column, so the row of data is unnecessary.
  6. Finally to sort, first click 'A' to highlight the column. From the 'Home' tab at the top, choose 'Sort & Filter' and select 'Sort Smallest to Largest'. If a menu pops up about whether or not to expand the selection, leave it the way it is and click 'Sort'. Since we only have one column of data, this is not relevant.
At the end of this process, all of the numbers will be sorted in a column in an Excel sheet. When there are many entries of data to input, this method of processing will be much efficient than simply typing each one out.