Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
John,
You don't need VBA, you can do this simply with worksheet formulae. In essence, what you do is to force it into a pseudo-time format and display it that way. Let's assume that the data is in column A, and we will start with A1, and put the result in B1. As Excel holds time as a fraction of 1 day, you start by dividing the value in A1 by 24 to convert to a fraction of 1 day, and because Excel 1900 date system cannot handle negative dates, we will take the absolute value =ABS(A1/24) You could then format this with the custom format "[h].mm.ss" and get the answer of 26.07.24, but that does not differentiate between N and S and you want more so we won't do that, we will continue. Next we will add a N/S indicator. To do that we will just add a test whether A1 is negative or not and string a value at the end. =ABS(A1/24) & IF(A1<0,"S","N") Pretty good, but as we have general format on the cell, it comes out like 1.088475N which is not what you want. So we now have to format the pseudo-time part bit, and we can do that in the formula by using the TEXT function =TEXT(ABS(A1/24),"[h].mm.ss") which gives us the same result as above if we had used custom cell formats. Put it all together, and we finally have in B1 =TEXT(ABS(A1/24),"[h].mm.ss") & IF(A1<0,"S","N") and I think that this is exactly what you want, so just copy it down column B. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Programming | Excel Discussion (Misc queries) | |||
ISERROR,SMALL,INDEX, MATCH, SMALL?? | Excel Discussion (Misc queries) | |||
ExCel programming | Charts and Charting in Excel | |||
Excel Programming | New Users to Excel | |||
Excel Programming help | Excel Worksheet Functions |