+ Reply to Thread
Results 1 to 13 of 13

Make print area dynamic & replace a SUMPRODUCT with code!

  1. #1
    Registered User
    Join Date
    06-15-2012
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    85

    Make print area dynamic & replace a SUMPRODUCT with code!

    Hello!

    I have this code

    Please Login or Register  to view this content.
    i'd like to modify in the last part the code(the print part) do the named range "myrange" to be dynamic!

    Also i use this SUMPRODUCT formula to get back some data from my other sheet.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    As my data sheet will include more that 10000 rows of data i know that the calculations will be too slow..

    So can we replace this SUMPRODUCT formula with a code to work faster?

    Note: I use SUMPRODUCT because this workbook works also in computers yhan use Excel 2003

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    If your actual data set is only 20 rows you could do that sumproduct as a loop without slowing things down too much:
    Please Login or Register  to view this content.
    I'm not entirely sure what you mean by make the named range dynamic - dynamically based on what?

  3. #3
    Registered User
    Join Date
    06-15-2012
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    My Named range, "myrange" use this formula.

    =Macro!$A$5:$C$22

    So will print only the data in this range.

    Saying that i need a dynamic range i mean that i need to print all the data for eatch time.

    Sometimes will be range A5:C20, ANOTHER a5:c120, another A5:C75 and so on . This is what i mean dynamically. Based on the last row filled with data.

    ..If your actual data set is only 20 rows you could do that sumproduct as a loop without slowing things down too much:
    No as i said in my first post..

    .
    .As my data sheet will include more that 10000 rows of data i know that the calculations will be too slow..
    For 20 or 100 rows no need of code. Formula works great! But for more than 10000 rows..?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    Try:
    Please Login or Register  to view this content.
    I can't think of way to code that sumproduct formula efficiently. I'd probably approach it by assigning the formula it to a cell and then reading the cell value.

  5. #5
    Registered User
    Join Date
    06-15-2012
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    No. This not works because printing Everything that exist in the whole sheet...

    I need to print the range A5:to the last used cell in Column C.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    Ok try
    Please Login or Register  to view this content.
    Last edited by Fotis1991; 09-20-2013 at 09:11 AM. Reason: added code tags

  7. #7
    Registered User
    Join Date
    06-15-2012
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    This works! Thank you.

    Can you pls explain what do you mean by this?

    I can't think of way to code that sumproduct formula efficiently. I'd probably approach it by assigning the formula it to a cell and then reading the cell value.

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    Please Login or Register  to view this content.
    Where A1 is a cell on your worksheet not in use you can use to hold a temporary value.

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    Actually, thinking about it, maybe you could do something like:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-15-2012
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    Perhaps it's sound sill question ..but how can i use your last code?

  11. #11
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    I guess you would want a custom function?

    Please Login or Register  to view this content.
    then in your cell
    =Sumproduct_Replacement(Data!$A$2:$A$20<,$B$1,Data!$B$2:$B$20,$C$1,Data!$C$2:$C$20)

  12. #12
    Registered User
    Join Date
    06-15-2012
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    Thank you!

  13. #13
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Make print area dynamic & replace a SUMPRODUCT with code!

    Is it noticeably quicker? You should probably add screenupdating off/on as well:
    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 09-05-2013, 03:32 AM
  2. [SOLVED] Need ‘Set Print Area’ Code for Dynamic Print Range based on Conditions
    By dosbirn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 12:13 PM
  3. Replies: 2
    Last Post: 01-04-2013, 04:22 PM
  4. [SOLVED] Dynamic print area
    By Harley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-10-2005, 09:20 AM
  5. Print Area:What would be the code for setting the print area
    By wammer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2005, 02:05 AM

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