Link to home
Start Free TrialLog in
Avatar of arcross
arcrossFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Convert cells in excel to text to number

Hi,
im exporting data to an excel sheet. Im adding som e formulas though vb.net to some cells.
But when i export the data the cells are store as text. I need to store certain cells as numbers.

How can i convert the cells to numbers?

thanks
Avatar of mfhorizon
mfhorizon

while storing excel formulas from vb.net or any other language, use equal sign (=) before the formula then it must calculate automatically.
Avatar of Alan
Hi,

If you want to use formulae then this is the form where A1 contains the text string "23":

=VALUE(A1)

which will then evaluate to the value 23.

Alan.

How do you export ? Can you show some code?
ASKER CERTIFIED SOLUTION
Avatar of Alan
Alan
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arcross

ASKER

im using the "=" for the formulas.

basically, what im doing is to loop the rows in a datatable and add store teh values in an array.
Then im adding the array of the values of the row in a range of cells.:

Sheet.range("A" & x.ToString, LastColumn & x.ToString).value = arrCell  
'Arrcell contains all the values from the row.

Then im adding an extra column with formula. TO calculate the values of two of those columns.
But it shows the rsult as 0. But if i change manually the cells i want to calculate from text to 'Convert to number' its fine.
So i need to convert the cells through code.
   
Hi,

I am not clear here.  Are you saying the code I posted above does not work for you (after adjusting the worksheet and range)?

Alan.
Avatar of arcross

ASKER

Hi Alan, yes it dows work! thanks!

It seems i was posting mine while you posted yours so i didnt see it!
Like ships passing in the night!

Glad it worked,

Alan.