>>>Hi All,
>>>
>>>I am using Excel automation to populate some cells with data. How can I tell Excel to format a cell as character before sending through the data?
>>>
>>>Thanks
>>
>>Hi. What Sergey states is what I usually do, too. Another alternative is to FIRST change the cell format to Text, THEN insert the value.
>
>OK, how do I change the cell format to text first ?
In Excel, the shortcut to access cell format is Ctrl-1. From the tab "Number", choose "Text".
The macro recorder shows:
Selection.NumberFormat = "@"
So that would probably translate to something like:
oSheet.Cells(nrow, ncol).NumberFormat = "@"
or for a larger range:
oSheet.Range(oSheet.Cells(1,1), oSheet.Cells(100,1)).NumberFormat = "@"
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)