+ Reply to Thread
Results 1 to 2 of 2

sum

Hybrid View

rcprito sum 03-13-2013, 12:30 PM
rcprito Re: sum 03-13-2013, 01:25 PM
  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    Porto
    MS-Off Ver
    Excel 2010
    Posts
    94

    sum

    hey guys.. I want to create a macro that says to me that when the sum of Combobox3.value + Combobox4.value > 100 It sends me a error message..

    the problem is when I insert a number in combobox4, no matter if sum of them is >100 or <100 it gives me the error message..

    here it is the code..

    Private Sub ComboBox4_Change()
    
    If ComboBox3.Value + ComboBox4.Value > 100 Then
    
    MsgBox ("Soma superior a 100%"), vbCritical, "Mensagem de Erro"
    
    ComboBox4.Clear
    ComboBox4.ListIndex = -1
    
    Dim rcnt As Long ' codigo para a variavel ordem de extrusao ir à lista
        
        rcnt = Folha5.Range("T" & Rows.Count).End(xlUp).Row
        
    For i = 2 To rcnt
    
    ComboBox4.AddItem Folha5.Range("T" & i)
    
    Next
        
    End If
    
    If ComboBox4.Value > 0 And ComboBox4.Value < 100 Then
    TextBox10.Enabled = True
    End If
    thanks a lot

  2. #2
    Registered User
    Join Date
    02-27-2013
    Location
    Porto
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: sum

    Private Sub ComboBox4_Change()
    
    Dim x As Single
    Dim y As Single
    
    x = Val(ComboBox3.Text)
    y = Val(ComboBox4.Text)
    
    If Str(y + x) > 100 Then
    
    MsgBox ("Soma superior a 100%"), vbCritical, "Mensagem de Erro"
    
    ComboBox4.Clear
    ComboBox4.ListIndex = -1
    
    Dim rcnt As Long ' codigo para a variavel ordem de extrusao ir à lista
        
        rcnt = Folha5.Range("T" & Rows.Count).End(xlUp).Row
        
    For i = 2 To rcnt
    
    ComboBox4.AddItem Folha5.Range("T" & i)
    
    Next
        
    End If
    
    If y > 0 And y < 100 Then
    TextBox10.Enabled = True
    End If
    
    
    
    End Sub

    Solved..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1