Hi all I'm new to this forum.
I tried to search for answer but nothing found....
i have to make reports every day and i receive raw timing data like in attachment screenshot raw-data.jpg
and i am trying to add double zero only to cells which start with :
also i want to add single leading zero to cells which which start with hours 1 to 9
so basically the transformed data should look like this screenshot
can you please help me find formula to do this transformation?
Last edited by godlev; 09-02-2011 at 05:21 AM. Reason: solved
Hi godlev,
I think you could use the FIND formula with a few IF statements here to do this.
If your data is in cell A1, you could enter a formula in cell B1 that says:
=IF(FIND(":",A1)=1,"00" & A1,IF(FIND(":",A1)=2,"0" & A1,A1))
This is saying:
If the position of a colon ( : ) is the first character in the string, then it means you need to add a "00". Otherwise if the colon is the second character in the string, you need to add a single "0". Otherwise, the colon is not the first or second character, which must mean that you start with a two digit value (like "12" or whatever), so just return whatever is in A1.
This will mean that when you copy the formula down, you will have a list of formatted values (which you could paste over the original data if you wanted).
If you wanted to write over the data "in-situ", you would need to use it doing visual basic macros, which is possible, but a step up from formulas. In this case you could make it so that you can the range of cells that you are trying to update, and the macro will scan each cell in the selection and see if it needs to be modified.
Anyway, hope this helps.
Paul
Try this
Format the cells "hh:mm:ss"=IF(ISNUMBER(A1),A1,IF(LEN(TRIM(A1))=6,"00"&TRIM(A1),"00"&TRIM(A1)&"0"))*1
This will allow for Excel possibly automatically recognising say 1:00:00 or 11:00:00 as a time.
It should also handle examples like :00:4 should they occur.
[EDIT]
This extention of Pauls' suggestion might be better
This will handle numeric cells and blanks should they occur.=IF(OR(A1="",ISNUMBER(A1)),A1,IF(FIND(":",A1)=1,"00" & A1,IF(FIND(":",A1)=2,"0" & A1,A1))*1)
One thing to note my first suggestion will convert :00:4 to 00:00:40,
Pauls' formula will return 00:00:04
Last edited by Marcol; 09-02-2011 at 05:25 AM.
If you need any more information, please feel free to ask.
However, if this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody! ....
Also
If you are satisfied by any members response to your problem please consider using the small Star icon botom left of thier post to show your appreciation.
@PaulG2011 - BIG thank you for the swift reply - your formula works PERFECT!
@Marcol - thank you for your reply - your formula inserts single zero in front of the :
Case SOLVED!
The formule I offered, (in both cases), should convert the string to a number.
If the cells are formatted "hh:mm:ss" then all should work.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks