Home » excel » types – Force Excel 2007 to treat all values in a column as text

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

Posted by: admin March 5, 2020 Leave a comment

Questions:

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.

How to&Answers:

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.

Answer:

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.

Answer:

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.

Answer:

Have you tried setting the cells’ number format to “Text”?

In Excel 2003: Format > Cells… > Number > Category: Text.

I don’t have the more recent Excel versions, but it has to be something similar.

Answer:

I tried all the above but didn’t work. And then added an apostrophe before the number. Only then it changed to text from the exponential notation.

Answer:

If you already have your data and manually adding a quote in front of your data in each cell is not an option you can use a helper column and write

="'"&A1

in B1, where A1 is the reference to your cell, and drag down the formula in B1 to the bottom. At this point you will see the quote, and you need to paste data in column B as values (CTRL+C & ALT+E+S and select values, or paste special as values from the top menu). Then find+replace a ‘(quote) with a ‘(quote) and you will have a column with values forced to text and a quote in front of each numeral representation of the number.