View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Julie Julie is offline
external usenet poster
 
Posts: 150
Default Force a cell to display as Text


Thanks for your help... but I need a way without altering the data values
(via some kind of number formatting). For example, I tried

myRange.NumberFormat = ""; or
myRange.NumberFormat = "Text";

which didn't work. But I'm looking for a solution more along those lines.
Thanks a bunch!

"witek" wrote:

Julie wrote:
I am programmatically (via C#) placing data on an Excel spreadsheet. Problem
is that some of the data look like dates (e.g "4/22") which really are not
dates. Excel is automatically converting these to dates. When using Excel, I
can set the cell's format category to "Text" and it will display properly.
How do I do that programatically?


add "'" at the beginning of your text.

var = "'" + var

and now Excel will see it as text.