Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Time displaying as decimal

I am working on some macros to automate charting and am having trouble with
the column that contains the times (x values).

In particular, the column is formatted as type "Custom hh:mm" and so I
simply tried the following:

strDateStart = ActiveCell.Value

which returns a decimal time. I have tried applying the TimeValue function
to the cell contents

strDateStart = TimeValue(ActiveCell.Value)

but it gives me a type mismatch error.

Could anyone please shed any light on this.

Thanks a lot

P.S. The Excel spreadsheet has been itself auto-generated via a third party
Delphi application. So I cannot control the original format of the source
data.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Time displaying as decimal

The value is a fractional amount - that's how XL stores times, as
fractional days. You could use

strDateStart = ActiveCell.Text

if you want to rely on the cells' formatting.

Or you might try

strDateStart = Format(ActiveCell.Value, "hh:mm")

to make sure you have the format you want.

In article ,
"MauroBCT" wrote:

I am working on some macros to automate charting and am having trouble with
the column that contains the times (x values).

In particular, the column is formatted as type "Custom hh:mm" and so I
simply tried the following:

strDateStart = ActiveCell.Value

which returns a decimal time. I have tried applying the TimeValue function
to the cell contents

strDateStart = TimeValue(ActiveCell.Value)

but it gives me a type mismatch error.

Could anyone please shed any light on this.

Thanks a lot

P.S. The Excel spreadsheet has been itself auto-generated via a third party
Delphi application. So I cannot control the original format of the source
data.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Time displaying as decimal

Obvious isn't it ;- ? Thanks very much for your help.

"JE McGimpsey" wrote:

The value is a fractional amount - that's how XL stores times, as
fractional days. You could use

strDateStart = ActiveCell.Text

if you want to rely on the cells' formatting.

Or you might try

strDateStart = Format(ActiveCell.Value, "hh:mm")

to make sure you have the format you want.

In article ,
"MauroBCT" wrote:

I am working on some macros to automate charting and am having trouble with
the column that contains the times (x values).

In particular, the column is formatted as type "Custom hh:mm" and so I
simply tried the following:

strDateStart = ActiveCell.Value

which returns a decimal time. I have tried applying the TimeValue function
to the cell contents

strDateStart = TimeValue(ActiveCell.Value)

but it gives me a type mismatch error.

Could anyone please shed any light on this.

Thanks a lot

P.S. The Excel spreadsheet has been itself auto-generated via a third party
Delphi application. So I cannot control the original format of the source
data.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying a decimal as years and months Chris Excel Worksheet Functions 14 April 23rd 08 09:06 PM
Displaying decimal places KnowledgeSeeker Excel Discussion (Misc queries) 4 April 2nd 07 09:34 PM
Displaying decimal places KnowledgeSeeker Excel Worksheet Functions 4 April 2nd 07 09:34 PM
If then statement displaying 2 or 3 decimal places Miles Excel Worksheet Functions 2 February 27th 07 12:44 AM
Displaying only digits after the decimal point Tat Excel Worksheet Functions 4 June 1st 05 06:13 PM


All times are GMT +1. The time now is 09:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"