+ Reply to Thread
Results 1 to 8 of 8

SUMIF into VBA Userform

  1. #1
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    SUMIF into VBA Userform

    I just added a formula to a table

    Please Login or Register  to view this content.
    and for some reason my userform that referenced that particular column now is very slow and is taking considerable amount of time to load and refresh.... not sure why this particular formula did affects it this way but when I remove it everything speeds up and when i add it everything slows down.

    is there a way to accomplish this formula in a vba code instead (i assume that might help speed things up).

    basically the textbox in the user form is called "billedtodate"....i would like to search table4 and sum all the values that match the job number entered into text box "JobSearch".

    table 4 contains the job number in column 1 and the $ amount in column 3.
    Last edited by adamheon; 07-09-2016 at 09:52 AM.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: SUMIF into VBA Userform

    Just for testing purposes.
    Please Login or Register  to view this content.
    Make sure table4 sheet is the activesheet, replace red 1 by some job number and run code.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: SUMIF into VBA Userform

    If there is nothing above/below the table on the sheet I would be tempted to use a nice simple approach such as:
    Please Login or Register  to view this content.
    Sheet names and ranges would need altering to suit obviously.

    BSB

  4. #4
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: SUMIF into VBA Userform

    Thanks BSB...worked perfect and everything is as fast as it was before! Thank you!

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: [SOLVED] SUMIF into VBA Userform

    Why calculate entire column ?
    Please Login or Register  to view this content.

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: SUMIF into VBA Userform

    Good point, well raised! However, what would be the advantage of running 4 lines of code to calculate on a smaller range over 1 line of code to calculate the entire column? Speed?

    Keep in mind that there is an upper limit on the amount of code you can have in a UserForm before you receive the "Procedure too large" message and need to start moving code into modules. We have no idea how complex the UserForm in question here is. 4 lines of code could be enough to tip it over the edge.

    Having said that, your 4 lines could of course be condensed into 1 line, but it would still be longer than the 1 line I suggested and still provide no real benefit IMO.

    BSB

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: SUMIF into VBA Userform

    Keep in mind that there is an upper limit on the amount of code you can have in a UserForm before you receive the "Procedure too large"
    There's a 64kb upper limit in a module, before you reach that limit the human mind has given up a long time before in trying to understand what that code with such length is all about.

    And yes IMO speed is of great importance. This is a simple formula but with more complex formulas every line that hasn't to be calculated is one line won.
    Last edited by bakerman2; 07-10-2016 at 02:31 AM.

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: SUMIF into VBA Userform

    Haha! I agree, but I've seen many multipage userforms with many many controls and the code DOES run beyond that.

    64k really isn't that much code.

    All I'm saying is, this could be one of those userforms that suffers from it.


    BSB

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. SumIf formula or Sumif with pivottable combined question
    By mcgleeuw in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-10-2015, 01:05 PM
  2. Replies: 4
    Last Post: 12-04-2014, 02:06 PM
  3. [SOLVED] Shorten SUMIF + SUMIF + SUMIF each with same reference range but different criteria???
    By HeyInKy in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-13-2014, 09:25 PM
  4. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-04-2014, 07:11 AM
  5. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2014, 12:28 PM
  6. [SOLVED] Open a userform from a userform, but preserve the info in the original userform
    By jfoerch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2013, 02:38 PM
  7. userform is large.....how to use scrollbar of userform to show all of the userform
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2010, 04:11 PM

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