![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Location: Baltimore
Posts: 29
|
anyone know how to create a function that will convert miles to kilometers?
1 mile = 1.6093 kilometers create a function so that the user can enter a mile amount in a cell the function could reference that cell and show the kilometer amount |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: May 2002
Posts: 13,278
|
I might be missing the point here, but if A1 contains the miles value, then =(a1*1.6093) gives you the kilometers.
Post if I've totally misunderstood what the problem is, Paddy |
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Location: Baltimore
Posts: 29
|
it must be a function the user can type in, such as "MileConverter(" whatever. Has to be done in a vba module i think.
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,029
|
G'day,
How about for your mile value in A2: =CONVERT(A2,"mi","m")/1000 (This converts Miles to Meters/1000 Adam |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
How about a UDF :
Function MtoKM(miles) MtoKM = miles * 1.6093 End Function |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,029
|
*slaps forehead*
Or actually this should work: =CONVERT(A2,"mi","km") Adam |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Wivenhoe, England
Posts: 877
|
I use a useful little utility called Convert which does all sorts of measurement conversions. It can be downloaded at http://www.joshmadison.com/software/convert
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Apr 2002
Location: Oregon
Posts: 77
|
Function Convert(ValRange)
Dim RangeArray As Variant RangeArray = ValRange.Value Convert = RangeArray * 1.6093 End Function Try this insert this code into a module. Type into a cell the number of miles. Go to the cell you want the klick value in and hit the = and go to user defined functions. Choose Convert then for your range pick the cell with the miles in it. This will return the klick value of that mile cell. |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2002
Location: Oregon
Posts: 77
|
Sorry... klick being slang for Kilometers. Let me know if that is what you wanted or not.
|
|
|
|
|
|
#10 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
Hi Inarbeth,
With which software you did this application? I am just curious whether you did it through excel ? [ This Message was edited by: jkpd2000 on 2002-05-15 06:49 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|