Consulting

Results 1 to 3 of 3

Thread: Solved: Sum condition

  1. #1
    VBAX Regular
    Joined
    Nov 2005
    Posts
    30
    Location

    Solved: Sum condition

    I'm using a spin button on a userform to alter an existing value (Label11) through a textbox. What I would like is to set a condition for Label27 so it can have any value as long as it's above 0 (zero).

    Example:
    Label27 value is 270 = Label27 value is 270
    Label27 value is -22 = Label27 value is 0

    [VBA]Private Sub SpinButton1_Change()
    Me.TextBox1 = Format(Me.SpinButton1.Value)
    Label27 = Label11 + CDbl(TextBox1.Value)
    End Sub[/VBA]

    Appreciate some help here...

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by ulfal028
    I'm using a spin button on a userform to alter an existing value (Label11) through a textbox. What I would like is to set a condition for Label27 so it can have any value as long as it's above 0 (zero).

    Example:
    Label27 value is 270 = Label27 value is 270
    Label27 value is -22 = Label27 value is 0

    [VBA]Private Sub SpinButton1_Change()
    Me.TextBox1 = Format(Me.SpinButton1.Value)
    Label27 = Label11 + CDbl(TextBox1.Value)
    End Sub[/VBA]

    Appreciate some help here...

    [vba]
    Label27.Caption = CStr(Application.MAX(0, Label11.Caption + CDbl(Textbox1.Text)))
    [/vba]

  3. #3
    VBAX Regular
    Joined
    Nov 2005
    Posts
    30
    Location
    Works great. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •