View Single Post
 
Old 04-16-2006, 11:03 PM
chesspupil chesspupil is offline Windows XP Office 2003
Novice
 
Join Date: Apr 2006
Posts: 8
chesspupil
Default

DD to DMS partly working below:

Function Convert_Degree(Decimal_Deg) As Variant
With Application
'Set degree to Integer of Argument Passed
Degrees = Int(Decimal_Deg)
'Set minutes to 60 times the number to the right
'of the decimal for the variable Decimal_Deg
Minutes = (Decimal_Deg - Degrees) * 60
'Set seconds to 60 times the number to the right of the
'decimal for the variable Minute
Seconds = Format(((Minutes - Int(Minutes)) * 60), "0.000")
'Returns the Result of degree conversion
'(for example, 10.46 = 10~ 27 ' 36")
Convert_Degree = Degrees & Int(Minutes) & Seconds
End With



This works as a VB module in Excel I removed the Deg, Min and Sec marks as they are unwanted int the output. (you can see the exmple in the formula)

Here is my problem. If DD, MM, or SS.000 = <10 then I lose a needed placeholder.

So placing the value in cell A1 and then [=Convert_Degree(A1)] minus brackets I get:

34.75 = 34450.000 I need to have the leading zero in the SS position.

or 2.0523 = 238.280 and here I have 3 bad fields, all needing a zero for a corrected output of
020308.280

I also need to still add the arguemnt to add a N or S / E or W to the end of the output.

Ultimately Collum header A1 / B1 would read LAT or LONG and be the defining variable to answer if N or S is used or W or E is used

Something like:

if Degrees<0 and A1 = LAT then Convert_Degree = Degrees & Int(Minutes) & Seconds "S"
else if A1 = LAT then Convert_Degree = Degrees & Int(Minutes) & Seconds "N"


if Degrees<0 and B1 = LONG then Convert_Degree = Degrees & Int(Minutes) & Seconds "W"
else if B1 = LONG thenConvert_Degree = Degrees & Int(Minutes) & Seconds "E"



Anyone have any ideas from this point? I will try to come up with a list of values to play with. It like I have a map but I'm without my glases.


PS I did search the forum fist but my formatting needs are unique.
Reply With Quote