+ Reply to Thread
Results 1 to 5 of 5

Form Help needed

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241

    Form Help needed

    Hi All,
    I have a user form with several textboxes. One box has "$Amount".
    what I am trying to do is when the user click the button after data input, the total from the amount column should appear in dialog box. What could be the script for this? The range will change each time an entry is made.
    Thank you for your help
    Syed

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Saziz,

    Could you post your code so it it more clear what you want the code to do?

    Thanks,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241
    Hi Leith Ross,
    here it is:

    Private Sub CommandButton3_Click()
    Dim lastrow As Object
    Dim mysum As Variant

    Set mysum = Sheet1.Range("g2")

    Set lastrow = Sheet1.Range("a65536").End(xlUp)
    lastrow.Offset(1, 0).Value = TextBox1.Text
    lastrow.Offset(1, 1).Value = TextBox2.Text
    lastrow.Offset(1, 2).Value = TextBox3.Text
    lastrow.Offset(1, 3).Value = TextBox4.Text

    lastrow.Offset(1, 5).Value = TextBox5.Text

    lastrow.Offset(1, 4).Value = ComboBox1.Value

    'MsgBox ("The total untill now is " & mysum)

    End Sub

    Originally I wanted it sum column G through code. Col. F has the $amount. All I want is to sum where ever is the last entry in Col. F Now what I did is dedicated a range (G2) for the total of the column F
    I would still be interested in the systax.
    Thank you
    Syed

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Syed,

    This will sum columns "F" through "I" on the last line entered on the worksheet with the values of the TextBox and CombBox then place the sum in cell "G2".


    Private Sub CommandButton3_Click()
      Dim lastrow As Long
      Dim mysum As Variant
    
        Set mysum = Sheet1.Range("G2")
    
        Set lastrow = Sheet1.Range("A65536").End(xlUp)
    
           With Sheet1.Cells(lastrow, "F")
             MySum = MySum +  .Offset(0, 0).Value = TextBox1.Text
             MySum = MySum +  .Offset(0, 1).Value = TextBox2.Text
             MySum = MySum +  .Offset(0, 2).Value = TextBox3.Text
             MySum = MySum +  .Offset(0, 3).Value = TextBox4.Text
             MySum = MySum +   ComboBox1.Value 
             MySum = MySum +   TextBox5.Text
          End with
    
      MsgBox ("The total untill now is " & mysum)
    
    End Sub
    

  5. #5
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241
    Leith
    Thank you so much for the help.
    syed

+ 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