• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Set the code to get the textbox values in Userform

Hany ali

Active Member
Hello my Dear
Please I want to Set the code to get the textbox values..for Exalmple when I choose any Items from ComboBox1 and put any figure in TextBox1 as 200
i want the Result for TextBox2 ,TextBox3 and TextBox4 as data in Sheet 1 ,when i choose item A and Put 200 in TextBox1 ,it will be textBox2.value =(200*66%)is 132
and textBox3.value =(200*84%)is 168.......... etc
Code:
Private Sub CommandButton1_Click()
On Error Resume Next
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
Me.TextBox2.Value = (Val(Me.TextBox1.Value) * WorksheetFunction.VLookup(Val(Me.ComboBox1.Value), ws.Range("a2:d20"), 2, 0))
Me.TextBox3.Value = (Val(Me.TextBox1.Value) * WorksheetFunction.VLookup(Val(Me.ComboBox1.Value), ws.Range("a2:d20"), 3, 0))
Me.TextBox4.Value = Me.TextBox1.Value * WorksheetFunction.VLookup(Val(Me.ComboBox1.Value), ws.Range("a2:d20"), 4, 0)
End Sub
 

Attachments

  • Percentage.xlsm
    19.3 KB · Views: 10
  • Untitled.png
    Untitled.png
    151.6 KB · Views: 5
Following change works for me:

Code:
Me.TextBox2.Value = Me.TextBox1.Value * WorksheetFunction.VLookup(Me.ComboBox1.Value, ws.Range("a2:d20"), 2, 0)
Me.TextBox3.Value = Me.TextBox1.Value * WorksheetFunction.VLookup(Me.ComboBox1.Value, ws.Range("a2:d20"), 3, 0)
Me.TextBox4.Value = Me.TextBox1.Value * WorksheetFunction.VLookup(Me.ComboBox1.Value, ws.Range("a2:d20"), 4, 0)
 
Back
Top