+ Reply to Thread
Results 1 to 5 of 5

Conditionally Sum Values in Column and Display Sum in Form Field

Hybrid View

Southfish Conditionally Sum Values in... 06-18-2012, 02:11 PM
RaulRodriguez Re: Conditionally Sum Values... 06-18-2012, 03:26 PM
RaulRodriguez Re: Conditionally Sum Values... 06-18-2012, 03:31 PM
Southfish Re: Conditionally Sum Values... 06-19-2012, 02:14 PM
Southfish Re: Conditionally Sum Values... 06-22-2012, 08:14 PM
  1. #1
    Registered User
    Join Date
    04-27-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    33

    Conditionally Sum Values in Column and Display Sum in Form Field

    I have a form that has a value in a field and have made many attempts to use that value to select a range from a table on the basis of the value in the form field and then sum the values in the column that met the condition (in form field) and display a running total of the sum in another field on the form.


    I've attached a sample file for clarity.

    Any assistance wuld be greatly appreciated as it appears to be beyond my skill level.

    Thanks.ShipTotTest.xls

  2. #2
    Forum Contributor
    Join Date
    05-04-2012
    Location
    Stamford,Connecticut,USA
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Conditionally Sum Values in Column and Display Sum in Form Field

    Replace your code in the command button1 with the following code:
    Fltr = UserForm1.TextBox1.Value
    shiptotest (Fltr)
    This code will basically read what you have typed on the text box and then will call a sub called shiptotest passing the parameter you keyed in textbox1.
    This is the code you want to populate textbox2:

    Sub shiptotest(Fltr)
        Columns("B:B").AutoFilter Field:=1, Criteria1:=Fltr
        iLastRow = Range("K65536").End(xlUp).Row
        i = WorksheetFunction.Sum(Range("K1:K" & iLastRow).SpecialCells(xlCellTypeVisible))
       UserForm1.TextBox2 = i
    End Sub
    If this is helpful please click on the Star icon to add to user's reputation and also mark your question as answered

  3. #3
    Forum Contributor
    Join Date
    05-04-2012
    Location
    Stamford,Connecticut,USA
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Conditionally Sum Values in Column and Display Sum in Form Field

    Here is a file
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-27-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Conditionally Sum Values in Column and Display Sum in Form Field

    Works great!!!

    I was totally on the wrong path to solving this issue.

    Thanks so much.

  5. #5
    Registered User
    Join Date
    04-27-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Conditionally Sum Values in Column and Display Sum in Form Field

    Raul,

    I've been trying to add a second criteria for the filter and sum in the above file "Test.xls", but haven't been successful.

    I'm trying to use column D (BoxNo) as the second condition to sum.

    Can you help?

+ 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