Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Convert range values to correct "hh:mm:ss" format.

When exporting data from another application as an excel worksheet I
end up with it in the following format.

Stat 1 Stat 2
Person1 01:16:00 01:09:25
Person2 :18 :49:12

I want to macro that will convert all the data in the range to
"hh:mm:ss".
Just applying data type cell formatting as hh:mm:ss does not fix the
values for Person2 and seems excel just treats it as text.
What is the most efficient way to do a check of all the data and then
fix the value of the data that is not in the correct format to
hh:mm:ss.

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Convert range values to correct "hh:mm:ss" format.

I would insert two helper columns to the right of each original column.

I used column C and Column E (B and D were the original columns).

I put this in C1:

=IF(ISNUMBER(B1),B1/60,IF((LEN(B1)-LEN(SUBSTITUTE(B1,":","")))=1,
--("0"&B1)/60,--("0"&B1)))
(all one cell)

Then I copied it to E1.

And dragged C1 done and E1 down as far as necessary.

I ended up with this (all formatted as hh:mm:ss):

A B C D E
Person1 01:16:00 00:01:16 01:09:25 00:01:09
Person2 :18 00:00:18 :49:12 00:49:12

Did :18 mean 18 seconds?
Did :49:12 mean 49 min 12 secs?




wrote:

wrote:
When exporting data from another application as an excel worksheet I
end up with it in the following format.

Stat 1 Stat 2
Person1 01:16:00 01:09:25
Person2 :18 :49:12

I want to macro that will convert all the data in the range to
"hh:mm:ss".
Just applying data type cell formatting as hh:mm:ss does not fix the
values for Person2 and seems excel just treats it as text.
What is the most efficient way to do a check of all the data and then
fix the value of the data that is not in the correct format to
hh:mm:ss.

Thanks.


Just a follow up,
The data for Person1, Stat1 in the original application was 1 minute
and 16 secs - 01:16 and this is in "mm:ss" but when taken to excel it
becomes 01:16:00 in "hh:mm:ss" instead of the "00:01:16" format that I
need it to be in.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Convert range values to correct "hh:mm:ss" format.

Thanks Dave,

It work almost fine, just that I should have clarified that the data
Person1, Stat2 01:09:25 when taken to excel is actually in the correct
format (hh:mm:ss) and does not need to be converted to anything, it
just needs to be left alone.

How can I tweak the formula to include this possibility.

thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Convert range values to correct "hh:mm:ss" format.

You'd have to use a different formula in column in E1.

=IF(ISNUMBER(d1),d1,IF((LEN(d1)-LEN(SUBSTITUTE(d1,":","")))=1,
--("0"&d1)/60,--("0"&d1)))

But I'm not sure what :49:12 meant.

So that last portion is still a guess.

wrote:

Thanks Dave,

It work almost fine, just that I should have clarified that the data
Person1, Stat2 01:09:25 when taken to excel is actually in the correct
format (hh:mm:ss) and does not need to be converted to anything, it
just needs to be left alone.

How can I tweak the formula to include this possibility.

thanks.


--

Dave Peterson


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
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
VLOOKUP won't generate correct response for "inbetween" values NavyPianoMan Excel Discussion (Misc queries) 9 August 28th 07 02:28 PM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Convert "Month" to "MonthName" format from db to PivotTable Billabong Excel Programming 1 August 25th 04 09:14 AM


All times are GMT +1. The time now is 04:02 AM.

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

About Us

"It's about Microsoft Excel"