Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Excel 2007 to treat all values in a column as text

Tags:

types

excel

I have a large column of data in Excel. This data should all be treated as text, but in some cells Excel is "magically" changing the data to numeric. This is screwing up my vlookpup() functions in another part of the spreadsheet, and I need to override Excel's automatic data type detection.

If I manually go through the cells, and append ' to each numeric cell, it works. I just don't want to do this by hand for several thousand cells.

For example, this works: Manually type '209

And this does not work: Manually type 209, right click and format as text.

like image 316
Zach Avatar asked Jun 30 '11 21:06

Zach


People also ask

How do you make all cells in a column say the same thing?

Insert the same data into multiple cells using Ctrl+Enter Select all the blank cells in a column. Press Ctrl+Enter instead of Enter. All the selected cells will be filled with the data that you typed.

How do I apply text to all cells?

Click on the text you want to fill onto the other cells and click on the Flash Fill option. The data will be copied onto the other cells related to the data. A shortcut of Flash Fill is Ctrl+E on keyboard.


3 Answers

Under the Data Tab, open the Text to Columns wizard and set the Column data format to Text. The destination cell can be set to the original data cell, but it will replace the original formatting with text formatting. Other aspects of formatting e.g. Bold, color, font, etc. are not changed using this method.

like image 97
JShrad Avatar answered Oct 17 '22 05:10

JShrad


Setting the cells to "Text" format, as Jean mentioned, should work. The easiest way to do this, in any version of Excel, is:

Right-click cell, "Format Cells", "Number" tab, select "Text" format.

like image 34
Steven Avatar answered Oct 17 '22 04:10

Steven


If changing the format of the column is not an option, it's helpful sometimes to create another column that's 'vlookup friendly' and leave your main column alone.

This is a trick I've used a few times:

Say your 'mixed' column is column A.

In column B, enter the formula:

 =CONCATENATE(A1)

or as Jean-François pointed out in a comment, the shorter version:

 =A1 & ""

And drag it down for to the bottom row.

Column B will be all strings. The VLookup can then use column B.

like image 15
Roy Truelove Avatar answered Oct 17 '22 06:10

Roy Truelove