How to change the property of a column in Excel Using VB.net

jacky2cool

New member
Joined
Oct 14, 2004
Messages
2
When i pass string like 00001234 to excel, the display will change to 1234 and in some cases, i pass 02-02 to excel and it display 02-Feb. I notice that changing the category of the column helps but how can i change it using VB.net
 
The best way to do it is to set the Range.NumberFormat to Text. It would look something like this:
Code:
Dim Rng As Excel.Range
Rng = xlApp.Range("..")   <-- Define the Range by Address here
Rng .NumberFormat = "@"   <-- The "@" is Text Format
To do this for an entire column on a Worksheet, you could do something like this:
Code:
Dim WS As Worksheet
Set WS = xlApp.Worksheets("Sheet1")
WS.Columns(1).NumberFormat = "@"
-- Mike
 
Back
Top