Hello,
In a sheet a have the following function :
Public Function feetAndInchToMeters(feet, inch) As Single
Dim sngFeet As Single
Dim sngInches As Single
Dim sngMeter As Single
Dim feet2Meter As Single
Dim inch2Meter As Single
sngFeet = feet
sngInches = inch
feet2Meter = 0.3048
inch2Meter = 0.0254
ActiveCell.NumberFormat = quot;0.00 \mquot;
sngMeter = (sngFeet * feet2Meter) (sngInches * inch2Meter)
feetAndInchToMeters = sngMeter
End Function
when I asign the function to a cell and insert the values 5 and 3 I get the
number 1,6002 in sted of 1,60 m what is wrong whith my function ?
Thanks in advance,
Benny
I don't think you can apply cell formatting from a function, only calculate
results
Apply your formatting manually, or return the answer as text formatted the
way your wishquot;BenCooquot; wrote:
gt; Hello,
gt;
gt; In a sheet a have the following function :
gt;
gt; Public Function feetAndInchToMeters(feet, inch) As Single
gt; Dim sngFeet As Single
gt; Dim sngInches As Single
gt; Dim sngMeter As Single
gt; Dim feet2Meter As Single
gt; Dim inch2Meter As Single
gt;
gt; sngFeet = feet
gt; sngInches = inch
gt; feet2Meter = 0.3048
gt; inch2Meter = 0.0254
gt; ActiveCell.NumberFormat = quot;0.00 \mquot;
gt; sngMeter = (sngFeet * feet2Meter) (sngInches * inch2Meter)
gt;
gt; feetAndInchToMeters = sngMeter
gt; End Function
gt;
gt; when I asign the function to a cell and insert the values 5 and 3 I get the
gt; number 1,6002 in sted of 1,60 m what is wrong whith my function ?
gt;
gt; Thanks in advance,
gt;
gt; Benny
gt;
gt;
gt;
- May 16 Wed 2007 20:37
Format numberformat Single
close
全站熱搜
留言列表
發表留言