Problem reading value from Excel spreadsheet

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

Hello,
My code imports data from Excel spreadsheet.
The line of code is:
oExcelWS.Cells(Row, Column).Value
All is fine when cell contains text or number, however one cell contains
time in 24 hrs format"
for example 22:35
When reading that cell value the result is not 22:35 but 0.78333...
I understand that Excel does calculation in here but I need to read the
original cell value without any transformation.
What can be done about that?
Your thoughts appreciated,
Jack
 
Jack,
Use the .Text (what is displayed in the cell) property instead of the .Value
(what is stored in the cell).

NickHK
 
Thank you.
That solved the problem.
I have noticed one strange thing though.
One spreadsheet's column contains phone numbers.
When I use .Value property the phone numbers are read properly, however when
using .Text property the phone numbers are changed when the column is not
wide enough to display the whole number.
for example:
8562200430 is changed to one of the following numbers (depending on the
column width):
8.562E+09
8.56E+09
8.6E+09
9E+09
#####
I believe it is a normal Excel behaviour but what is the reasoning behind
that?
Thanks,
Jack
 
Jack,
..Text gives you what actually appears in the cell, due formatting , or in
this case insufficient column width.
You would need to widen (or Autofit) the column to get a meaningful result.
Value is the same, no matter how it is actually displayed.

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top