ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CopyFromRecordset text to numeric (https://www.excelbanter.com/excel-programming/357428-copyfromrecordset-text-numeric.html)

[email protected]

CopyFromRecordset text to numeric
 
Hi,
how to recalculate text cell value after formating cell to numer?
....
cmd.CommandText ="select money(text value), money2(text value),
money3(text value) from money"
....
xlWs.Cells(1, 1).CopyFromRecordset(rs)
xlWs.Columns("A:A").NumberFormat = "0.00"
....

After executing values at cell looking like text(1.89898) but cell
formating is numer. After clicking the cell value changing to
numer(1.9) and you can count total money values. Is the is any way to
recalculate/change cells to be number?
--D.


Dick Kusleika[_4_]

CopyFromRecordset text to numeric
 
D

Try

xlWs.Columns(A:A).Value = xlWs.Columns(A:A).Value

after you change the NumberFormat.

--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com

wrote:
Hi,
how to recalculate text cell value after formating cell to numer?
...
cmd.CommandText ="select money(text value), money2(text value),
money3(text value) from money"
...
xlWs.Cells(1, 1).CopyFromRecordset(rs)
xlWs.Columns("A:A").NumberFormat = "0.00"
...

After executing values at cell looking like text(1.89898) but cell
formating is numer. After clicking the cell value changing to
numer(1.9) and you can count total money values. Is the is any way to
recalculate/change cells to be number?
--D.




NickHK

CopyFromRecordset text to numeric
 
andrei,
Or convert in your SELECT statement, using CLng, CAST etc depending on the
DB.

NickHK

wrote in message
ups.com...
Hi,
how to recalculate text cell value after formating cell to numer?
...
cmd.CommandText ="select money(text value), money2(text value),
money3(text value) from money"
...
xlWs.Cells(1, 1).CopyFromRecordset(rs)
xlWs.Columns("A:A").NumberFormat = "0.00"
...

After executing values at cell looking like text(1.89898) but cell
formating is numer. After clicking the cell value changing to
numer(1.9) and you can count total money values. Is the is any way to
recalculate/change cells to be number?
--D.




[email protected]

CopyFromRecordset text to numeric
 
Thanx that what i was looking for!!Cool!!


[email protected]

CopyFromRecordset text to numeric
 
xlWs.Columns(A:A).Value = xlWs.Columns(A:A).Value
That is working, unfortunatly at that situation i cant use cast,
convert function....but thanx for help
--D.



All times are GMT +1. The time now is 05:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com