VBA excel userform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomy01
    New Member
    • Jul 2010
    • 1

    VBA excel userform

    Can anyone please show me how to multipy(user input) four text boxes of user form 1 with four text boxes of user form 2 and store the value in any cell .Thank you.

    (Userform1.Text Box1.Value = Userform2.TextB ox1.Value ) +(Userform1.Tex tBox2.Value = Userform2.TextB ox2.Value)+ (Userform1.Text Box3.Value = Userform2.TextB ox3.Value)+ (Userform1.Text Box4.Value = Userform2.TextB ox4.Value) =
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by tomy01
    Can anyone please show me how to multipy(user input) four text boxes of user form 1 with four text boxes of user form 2 and store the value in any cell .Thank you.

    (Userform1.Text Box1.Value = Userform2.TextB ox1.Value ) +(Userform1.Tex tBox2.Value = Userform2.TextB ox2.Value)+ (Userform1.Text Box3.Value = Userform2.TextB ox3.Value)+ (Userform1.Text Box4.Value = Userform2.TextB ox4.Value) =
    The following code will multiply the Values in 4 Text Boxes on UserForm1 with the Values in 4 Text Boxes on UserForm2. For each UserForm, the Text Boxes are sequentially numbered TextBox1...Text Box4, and the result will be placed into Cell A1 of the Active Worksheet.
    Code:
    ActiveSheet.Cells(1, 1).Value = (UserForm1.TextBox1 * UserForm1.TextBox2 * UserForm1.TextBox3 * UserForm1.TextBox4) * _
                                    (UserForm2.TextBox1 * UserForm2.TextBox2 * UserForm2.TextBox3 * UserForm2.TextBox4)

    Comment

    • isac
      New Member
      • Jul 2010
      • 2

      #3
      Thank you .Its working .I would like to ask you one more thing is there any way to multiply four text box value of user form with four cells value in spreadsheet?

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by isac
        Thank you .Its working .I would like to ask you one more thing is there any way to multiply four text box value of user form with four cells value in spreadsheet?
        Yes, just use the Absolute Reference to the Cells in the Calculations.

        Comment

        • isac
          New Member
          • Jul 2010
          • 2

          #5
          Thank you again .I have no idea on vba,just trying to learn simple userform text box calculations .I was trying to do that way input in four text boxes and out put in cell C1,C2,C3,C4 after multiplying textbox1,2,3,4, with cell B1,B2,B3,B4.


          Sheets("data"). Range("C1") =TextBox1*Sheet s("data").Range ("B1")
          Sheets("data"). Range("C2") =TextBox2*Sheet s("data").Range ("B2")
          Sheets("data"). Range("C3") =TextBox3*Sheet s("data").Range ("B3")
          Sheets("data"). Range("C4") =TextBox4*Sheet s("data").Range ("B4")

          Private Sub Textbox1_change ()
          If IsNumeric(textb ox1) Then
          Sheets("data"). Range("C1") =TextBox1*Sheet s("data").Range ("B1")
          End if
          End Sub
          Private Sub Textbox2_change ()
          If IsNumeric(textb ox2) Then
          Sheets("data"). Range("C2") =TextBox2*Sheet s("data").Range ("B2")
          End if
          End Sub
          Private Sub Textbox3_change ()
          If IsNumeric(textb ox3) Then
          Sheets("data"). Range("C3") =TextBox3*Sheet s("data").Range ("B3")
          End if
          End Sub
          Private Sub Textbox4_change ()
          If IsNumeric(textb ox4) Then
          Sheets("data"). Range("C4") =TextBox4*Sheet s("data").Range ("B3")
          End if
          End Sub

          Comment

          Working...