View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe User[_2_] Joe User[_2_] is offline
external usenet poster
 
Posts: 905
Default Rounding a formula in code

"ordnance1" wrote:
How can I round this out to the 4th digit?
TextBox13.Value = (TimeValue(TextBox12.Value)
- TimeValue(TextBox11.Value)) * 24


TextBox13.Value = Round((TimeValue(TextBox12.Value) _
- TimeValue(TextBox11.Value)) * 24, 4)

or

TextBox13.Value = WorksheetFunction.Round((TimeValue(TextBox12.Value ) _
- TimeValue(TextBox11.Value)) * 24, 4)

The difference is that VBA Round does "banker's rounding". Compare
Round(2.5,0) and WorksheetFunction.Round(2.5,0).

PS: I will try to send email to the address that you used above. If you do
not see my message, please check this thread again for an off-topic
follow-up.