View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default function to change metric measurements

A1=1234

in b1:

=convm(a1,"m")


Function ConvM(ByVal metric As Long, munits As String) As String
Select Case munits
Case Is = "m"
cm = (metric Mod 1000) / 10
m = Int(metric / 1000)
ConvM = Str(m) & " m" & Str(cm) & " cm"
Case Is = "cm"
cm = metric / 10
ConvM = Str(cm) & " cm"
Case Is = "mm"
mm = metric
ConvM = Str(mm) & " mm"
Case Else
ConvM = "Invalid Units"
End Select

End Function

"devo" wrote:

Hi

i requre a little bit of guidance and help to right a simple function

I have a value in milimeters which i want to pass to a function followed by
a string or value to show that i want the result converting in to

a) meters & cm - lets call it m
b) cms & mm - lets call it cm
c) mm - lets call it mm

even though i passing the mm's to the function as a number i wish it to
display it as a string

thus 1234,m i wish to return as 1 m 23.4 cm
or 1234,cm will return 123 cm 4 mms or 123.4 cms
or 1234 mm will return 1234 mms


I know this should be easy but i just cant seem how i should structure my
login..

was trying to use mod and fix .. i cant see why i can get my head round it..
as i done something similar for inches and passing the factor of the inches
.... ie 1/8th 1/16th etc to it.. to display feet inches and denominator...

please help..