Changing time format to numeric

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I programatically change a derived time format displayed as 8:00:00
(hours - derived from a formula finish time minus start time) to the numeric
format 8 in a cell - can it be done?
 
Just as dates are stored behind the scenes as days counting from 1/1/1900,
times are stored as fractions of a day (0 is midnight last night, .5 midday,
1 midnight tonight). So, you just need to multiply your time by 24 to get
the actual hours.
 
Thanks for all the responses but they unfortunately still don't resolve my
problem. While this works fine when modifying Excel manually on the
worksheet, I need to be able to do it with the use of code which so far I
have been unable to do.

The code I tried was
xlApp.Application.Range(A8:H38) = xlApp.Application.Range(Cells(8, 8),
Cells(36, 8)).Value *24

Also the range to be changed is not actually A8:H36 - it is A8 to end of
file as all the worksheets are of different length with differing amounts of
rows. Any ideas on what I'm doing wrong guys?
 
Hi

You can multiply in this way the value in single cell. To do so with a
range, you or cycle through cells in range, and multiply every cell value
with 24 separately, or you use an VBA equivalent for a technique, where you
copy some cell with value 24 in it, and then use PasteSpecial>Multiply on a
range with time values.
 

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