Convert Degree Minutes to decimal degrees - excel

I have location points collected from a garmin device stored in an excel sheet in Degree Minutes format ---
W00208.172,N1046.977
How can I convert it to either Decimal Degrees or Degrees Minutes seconds Format ?

So I was looking for a lazy answer and wasn't happy so gonna put here what I made in the end:
Wanting to convert between these two formats:
33°59'05.5"S 22°39'42.7"E and -33.98485,22.66186
The left being "Degrees Minutes Seconds" and the right being "Decimal"
Of course I have to make some assumptions so they are that it assumes your are following the above formats exactly.
Ok so first is from Degree to Decimal (the source being in cell B2):
=ROUNDDOWN(if(mid(B2,find(" ",B2)-1,1)="S","-","")&mid(B2,1,find("°",B2)-1)+mid(B2,find("°",B2)+1,find("'",B2)-find("°",B2)-1)/60+mid(B2,find("'",B2)+1,find("""",B2)-find("'",B2)-1)/60/60,5)&","&rounddown(if(right(B2,1)="W","-","")&mid(right(B2,find(" ",B2)-1),1,find("°",right(B2,find(" ",B2)-1))-1)+mid(right(B2,find(" ",B2)-1),find("°",right(B2,find(" ",B2)-1))+1,find("'",right(B2,find(" ",B2)-1))-find("°",right(B2,find(" ",B2)-1))-1)/60+mid(right(B2,find(" ",B2)-1),find("'",right(B2,find(" ",B2)-1))+1,find("""",right(B2,find(" ",B2)-1))-find("'",right(B2,find(" ",B2)-1))-1)/60/60,5)
And then from Decimal to Degree (the source being in cell C2):
=abs(ROUNDDOWN(left(C2,find(",",C2)-1))) & "°" & ROUNDDOWN((abs(left(C2,find(",",C2)-1))-abs(ROUNDDOWN(left(C2,find(",",C2)-1))))*60) & "'" & round(((abs(left(C2,find(",",C2)-1))-abs(ROUNDDOWN(left(C2,find(",",C2)-1))))*60- rounddown((abs(left(C2,find(",",C2)-1))-abs(ROUNDDOWN(left(C2,find(",",C2)-1))))*60))*60,1) & """"&if(value(left(C2,find(",",C2)-1))<0,"S","N")& " " & abs(ROUNDDOWN(RIGHT(C2,len(C2)-find(",",C2)))) & "°" & rounddown((abs(RIGHT(C2,len(C2)-find(",",C2)))-abs(ROUNDDOWN(RIGHT(C2,len(C2)-find(",",C2)))))*60) & "'" & round(((abs(RIGHT(C2,len(C2)-find(",",C2)))-abs(ROUNDDOWN(RIGHT(C2,len(C2)-find(",",C2)))))*60- rounddown((abs(RIGHT(C2,len(C2)-find(",",C2)))-abs(ROUNDDOWN(RIGHT(C2,len(C2)-find(",",C2)))))*60))*60,1) & """"&if(value(right(C2,len(C2)-find(",",C2)))<0,"W","E")
If only you could have variables in formulae... most of that is duplicate formulae with some simple enough rules...Anyway, hope it helps someone.

The range of longitude (E or W) is -180 to 180, so 3 digits
The range of latitude (N or S) is -90 to 90, so 2 digits
Take "W00208.172", take the first 3 digits and store it to degress:
deg = 002
Then take the rest as decimal minutes:
min = 08.172
Now convert to decimal degrees (DEG):
decDegrees = deg + min / 60.0
Same for latitude: except that degrees are now only 2 digits
N1046.977: Take 10 degrees, and 46.977 minutes.
For both think if you want to keep the "W" symbol:
Often it is better to mutiply with -1 in case of of "W" or "S", do this as last step in your conversion!
Negative decimal degrees means W (for longitude) or S (for latitude).
For your provides coordinates that means:
lat: North 10046.977 = 10 + 46.977 / 60 = 10.78295;
lon: (2 + 8.172 / 60) * -1 = -2.1362;
so that location should be in Burkina Faso, 15m near a road (= plausible) 5,52 km south east east of Dununuai

This formula works on Google Sheets for converting from the format 018°40.1333 to 18.66888833 and -34°01.0597 to -34.01766167
=IF(MID(B2,1,1) = "-", (INT(MID(B2, 1, SEARCH("°", B2) - 1)) - MID(B2, SEARCH("°", B2) + 1, len(B2))/60), (INT(MID(B2, 1, SEARCH("°", B2) - 1)) + MID(B2, SEARCH("°", B2) + 1, len(B2))/60))

Related

Can I calculate Geometric Angle numeric value

I want to find the Geometrical angle target based on the below inputs :
If 45 Degree angle has the numeric value of 762
Then what is the value of 63.75 and 26.25 degree values? How to do it?
Thank you.
We can find what you need based on the information that you have:
45 degrees (your base point of reference) is equivalent to 762 'units'
We can find the ratio between 45 and 762 using a formula (GCD is Greatest Common Divider):
Formula in C2 = (ratio)
=A2/GCD(A2,B2) & ":" & B2/GCD(A2,B2)<br>
E2= (ratio 1)
=A2/GCD(A2,B2)
F2= (ratio 2)
=B2/GCD(A2,B2)
Looking at the above image, we can see that for every 15 degrees there are 254 'other units'.
We can now use the ratio values for our calculations:
We can divide any value in degrees by 15 (ratio 1) and multiply the result by 254 (ratio 2) to get our answer:
Formula in B5 (copied down) =
=SUM(A5/$D$2)*$E$2
Note that the references to the ratio's (D2 & E2) are absolute references (with $) and will not change as the formula is copied.

Return Sum values only when the sum of them is the MAX sum based on another column

I'm either looking for a formula solution or vba code to calculate the data on cells L2 and M2.
Explanation
I've a table from column range G:I, the table is registering the days from 1 to 1000, the value is the amount sold ( it can be a credit or debit) , when is a Credit, column "I" will display "Good Day", otherwise "Bad day" for debits. All of this calculation is being processed correctly, the problem comes when I want to get the max sum value for either the consecutive "Good Days" or "Bad Days"
Day 1 and Day 2 are consecutive "Bad Days" and the sum of both values is 200 ( so far this is the maximum sum value ), the problem comes when I get again consecutive "Bad Days" and the sum of those values is greater than my initial consecutive max sum values. Day 500 and 501 are consecutive "Bad Days" and the sum of both is 600 ( that is what I want in cell L2). The same process for "Good Day"
Consecutive days mean more than 1 day either being "Bad Day" or "Good Day" , example, 2 days,4 days, 100 days,etc. Let's say I've got 100 consecutive "Bad Days" with a sum of 1000 , then I got 1 "God Day" and then I got 2 consecutive "Bad Days" with a sum of 5000 which is greater than the one I've got in the 100 consecutive "Bad days" before ( I will need the 5000 value on cell L2)
On the picture below, the first 2 days are consecutive "Bad days" and the total sum is 200 ( so far this is the max value). From day 4 to day 10 there 7 consecutive "Bad Days" and the total sum is 35 ( which is less than the total of previous consecutive values which was 200). Now Days 500 and 501 are 2 consecutive "Bad Days" and the total sum is 600 which is greater than the previous 2 consecutive days on day 1 and 2. 600 will be now my max value that I need on cell L2 ( if someone change the results or values, L2 must be updated too
In cell K3 use
=MAX(IF($I$2:$I$14=K2,$H2:$H14,0)+IF($I$3:$I$15=K2,$H3:$H15,0))
If you don't have Office 365, you need to confirm the formula with Ctrl+Shift+Enter.
Copy across to cell L3.
I've figured out how to do it by building a vba code to sum only the consecutive data groups when consecutive data on each cell is equal or greater than 2 but also if column on the left side of the cell has "POSITIVE" or "NEGATIVE" value ( if condition was not meet leave cell empty and go to next cell dow)
'Calcular Suma de Stops Seguidos
Dim IteracionesFinales As String
IteracionesFinales = (Fil_F - Fil_I)
'Rango descendente
Dim r As String
r = 9
'Restar Filas
Dim rf As Integer
'Maximo de itraciones
For i = 1 To IteracionesFinales
If Range("AA" & r).Value = "" Then
r = r + 1
Else:
rf = (Range("AA" & r).Value - 1) * -1
Range("AB" & r).Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-1]>=2,RC[-2]=""NEGATIVA""),SUM(R[" & rf & "]C[-4]:OFFSET(RC[-4],0,0)),"""")"
r = r + 1
rf = 0
End If
Next i
'Calcular Suma de Takes Seguidos
'Rango descendente
Dim r2 As String
r2 = 9
'Restar Filas
Dim rf2 As Integer
'Maximo de itraciones
For i = 1 To IteracionesFinales
If Range("AA" & r2).Value = "" Then
r2 = r2 + 1
Else:
rf2 = (Range("AA" & r2).Value - 1) * -1
Range("AC" & r2).Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-2]>=2,RC[-3]=""POSITIVA""),SUM(R[" & rf2 & "]C[-4]:OFFSET(RC[-4],0,0)),"""")"
r2 = r2 + 1
rf2 = 0
End If
Next i
Range("Q19").Select
ActiveCell.FormulaR1C1 = _
"=MAXIFS(R[-11]C[11]:R[370]C[11],R[-11]C[9]:R[370]C[9],""NEGATIVA"")"
Range("R19").Select
ActiveCell.FormulaR1C1 = _
"=MAXIFS(R[-11]C[11]:R[370]C[11],R[-11]C[8]:R[370]C[8],""POSITIVA"")"
The above code is putting the sum data by each group in the last 2 columns AB,AC . Then I just needed a MAXIFS function to get the max sum amount

How to convert a decimal number to numbers in days, hours, and min in Excel

I have a simple cell A2 (48.48333333). I want to convert this number to number of days, numbers of hours, and number of minutes. I expect to see 2 days, and 30 minutes (conversion note: numbers after the decimal (.) would be converted as follow: .50 = 30 minutes, .25 = 15 minutes, .75 = 45 minutes) in this example, .48333333 would be 30 minutes).
Here is my attempts so far but the result is not what I expected.
=INT(A2) & " Days " & INT(MOD(A2, INT(A2))*24) & " Hours and " & MINUTE(A2) & " Minutes"
=TEXT(A2, "d \d, h\hr, m \m")
Is there a link or method in Excel that I can convert A2 cell into days, hours, and minutes?
Use:
=INT(A2/24) & "d " & TEXT(A2/24,"h\h m\m")
This will do the job ONLY if the total hour is less than 768 (or 32 days) as being pointed out by #ForwardEd:
=TEXT(A1/24,"d\d h\h m\m")
OK I know this is old, but if someone found this looking for the answer as I did. Here is what you can do.
If you have decimal value in days. i.e 52.85385614
Which is: 52 days, 20 hours, 29 minutes, 33.171 seconds, you need to use a formula to format it. (value in cell B7, formula in cell C7)
=CONCAT(INT(B7),".",TEXT(B7-TRUNC(B7),"hh:mm:ss.000"))
This will produce a value of: 52.20:29:33.171

Convert feet and inches to decimal format

I have approximately 3600 heights with the format Feet-Inch-Inch-Eigth of an inch, so for example:
5103 = 5 feet, 10 and 3/8 inches
6000 = 6 feet
6022 = 6 feet, 2 and 2/8 inches
and I need to convert these to decimal format either with a formula or macro, so that the results for these would be:
5103 = 5.864
6000 = 6.000
6022 = 6.187
As I have 3600+ of these, manual work would be a pain. How can I convert this format to a decimal format of feet and inches?
With data in column A, in B1 enter:
=--LEFT(A1,1)+MID(A1,2,2)/12+RIGHT(A1,1)/(12*8)
and copy down:
NOTE:
this conversion yields decimal feet so that 2 feet 6 inches shows 2.5
EDIT#1:
If you need to accommodate more than 9 feet in column A, then the formula should be:
=--LEFT(A1,LEN(A1)-3)+MID(A1,LEN(A1)-2,2)/12+RIGHT(A1,1)/(12*8)
If you ever need to go the long route, a VBA UDF would seem to be the most expedient.
Function feet2dec(str As String) As Double
Dim v As Long, vtmp As Variant, tmp As String
Dim feet As Double
vtmp = Split(str, Chr(44))
For v = LBound(vtmp) To UBound(vtmp)
Select Case LCase(Right(Trim(vtmp(v)), 4))
Case "feet"
feet = feet + Val(Trim(Replace(vtmp(v), "feet", vbNullString, 1, -1, vbTextCompare)))
Case "ches"
str = Replace(vtmp(v), "inches", vbNullString, 1, -1, vbTextCompare)
str = Application.Trim(Replace(str, "and", vbNullString, 1, -1, vbTextCompare))
feet = feet + Application.Evaluate(str) / 12
End Select
Next v
feet2dec = feet
End Function
   

How to round down only numbers which are above 100 and ends with "05" - not using left and right formula

Formula is simple: =IF(CA4>1,CA4,CEILING(BT4*BY$2,5))
So I want to add in part of IF FALSE (CEILING) calculation which would round down numbers like 105, 205 to 100, 200 etc.
I know I can use some formula using RIGHT and LEFT, however I am wondering if there is mathematical solution...
Assuming you are happy with the results of your formula except where the latter part results in a figure greater than 100 and ending in 05, and in that case you want the result to be rounded down to the 100, then try this revised version
=IF(CA4>1,CA4,IF(MOD(BT4*BY$2,100)<=5,FLOOR(BT4*BY$2,100),CEILING(BT4*BY$2,5)))
ROUNDDOWN worksheet function is what you are looking for.
Example code:
A = 105
B = 205
C = ROUNDDOWN(A,-2)
D = ROUNDDOWN(B,-2)
MsgBox( "105 is Rounded down to " & C)
MsgBox( "205 is Rounded down to " & D)
This code will display as follows
105 is Rounded down to 100
205 is Rounded down to 200

Resources