Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the program that populates the cell with 0000 is doing something like this:
Dim myCell as range set mycell = somecellsomewhere mycell.value = "0000" Then excel will see the value as a number 0--just like if you typed in 0000. Maybe you could go back to that programmer and make sure that he or she populates it as a string: Dim myCell as range set mycell = somecellsomewhere mycell.numberformat = "@" 'text mycell.value = "0000" 'or mycell.value = "'0000" ===== If you know any value you pick up from excel is supposed to be a string 4 digits long, couldn't you do the formatting in C#? ==== One more thought... If the other program does something like: Dim myCell as range set mycell = somecellsomewhere mycell.numberformat = "0000" mycell.value = 0 Then that value is 0, but the display will show 0000. Maybe you can pick up what shows in the cell by using .text instead of .value In VBA, it would be: msgbox mycell.text 'not mycell.value MJ wrote: I am doing a small integration between two systems. One system exports data (I have no control over this) to Excel and I am reading from the Excel file to use the data elsewhere. Everything is fine except for one problem: it is possible that I will have a value for a cell such as "0000". This is intended to be a string (eventually, when I import it). It shows up in the Excel interface as "0000", but whenever I read from the cell it comes back as "0". I guess Excel assumes it is a number. Is there a way around this where I can get the value of a cell via code (I am using C# for reference) as is (eg "0000", not "0")? I am sorry if this has been previously asked, I was having a hard time getting accurate search results for this topic. Many thanks. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
suppress conditional formatting programmatically | Excel Discussion (Misc queries) | |||
textbox formatting programmatically | Excel Programming | |||
How to set programmatically focus on specified Excel row? | Excel Programming | |||
Programmatically check cell formatting | Excel Programming | |||
Programmatically reading data field values from PivotTable | Excel Programming |