View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Negative to zero code

Try this in the text box's _Change event:

Private Sub txtRemain_Change()
If Val(txtRemain) < 0 Then
txtRemain= 0
End If
End Sub


"Gabe" wrote:

I went in and formatted a cell to: 0;"0";0 so that all negative numbers will
be converted to zero. I have a textbox on a userform that I need to do the
same thing. What code would I use? I tried this but it doesn't work:

txtRemain.Value = Format(txtRemain.Value, "#,#00;""0""")

Any help would be greatly appriciated.

Thanks,
~Gabe