LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Small programming task in Excel VBA

On Sat, 12 Jul 2003 02:22:46 -0400, "John Johndon"
wrote in microsoft.public.excel.programming:

I am somewhat familiar with VB but never written anything for Excel at all,
so please be patient with me.

I need to run a macro or some VBA code to run on an Excel spreadsheet. The
spreadsheet consists of a couple of columns that contain latitudes and
longitudes. The latitudes (and longitudes) are in decimal format e.g
+26.1234 which needs to be converted into a degrees minutes and seconds
(DMS) format, the + or - sign signals either North or South latitude, so the
converted colum would look like 260724N which is 26 degrees, 07 minutes, and
24 seonds North.

[snip]
No VBA code necessary. A formula I came up with quickly is:
=(INT(ABS(A2))*10000+TEXT(INT(MOD(ABS(A2),1)*60)," 00")*100+INT(MOD(MOD(ABS(A2),1)*3600,60)))*SIGN(A2 )
will show 260724 when A2=26.1234 and -260724 when A2 = -26.1234

Formatting that with a hemisphere is left as an exercise for the
reader.

--
Michael Bednarek, IT Manager, Tactical Global Management
Waterfront Pl, Brisbane 4000, Australia. "POST NO BILLS"
http://mcmbednarek.tripod.com/
 
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
Excel Programming danjordan2000 Excel Discussion (Misc queries) 1 November 17th 08 01:20 PM
excel programming Wendy Elizabeth Charts and Charting in Excel 2 June 19th 07 04:21 AM
ISERROR,SMALL,INDEX, MATCH, SMALL?? M.A.Tyler Excel Discussion (Misc queries) 1 May 2nd 07 04:08 AM
Excel Programming Sprad-Dog New Users to Excel 2 July 13th 05 07:12 PM
Small programming task in Excel VBA Bob Phillips[_5_] Excel Programming 3 July 12th 03 07:40 PM


All times are GMT +1. The time now is 08:55 PM.

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"