+ Reply to Thread
Results 1 to 11 of 11

Problem with macro calculating on different data sets with different numbers of rows

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    82

    Problem with macro calculating on different data sets with different numbers of rows

    I'm still pretty new to using macros and would appreciate any help with the below :

    I have attached a data file and the macro. the macro calculates the lease term in years and gives a payout quote based on the lease term. This works fine for the attache data set (329 rows), however, when i try to use the macro on a larger data (1000 rows) it only calculates down to row 329.

    hopefully its something really simple that needs to be changed

    I would appreciate any help.

    thanks
    Attached Files Attached Files
    Last edited by a2424; 10-31-2012 at 07:09 PM.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Help with macro!

    Hi,
    You have 4 lines of code that need changing to whatever row you want to use

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    the number 329 is preventing any further data being filtered. Just change it to however many rows you want.
    Last edited by jeffreybrown; 10-31-2012 at 07:08 PM. Reason: Please use code tags...Thanks.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,438

    Re: Help with macro!

    I think this does the same as yours but is shorter, quicker and not limited to 329 rows:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    10-09-2012
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    82

    Re:Problem with macro calculating on different data sets with different numbers of rows

    hi,

    is it possible to change the range so it automatically calculates for any number of rows without having to change it everytime for a different number of rows?
    Last edited by a2424; 10-31-2012 at 07:10 PM.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,438

    Re: Problem with macro calculating on different data sets with different numbers of rows

    is it possible to change the range so it automatically calculates for any number of rows

    See post #3. That's what it does.

    Regards, TMS

  6. #6
    Registered User
    Join Date
    10-09-2012
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    82

    Re: Problem with macro calculating on different data sets with different numbers of rows

    thanks for your help TMS,

    I have tried extending your macro for a bigger set of data with more columns but its only calculating the top 3 rows. any idea what that is?
    Attached Files Attached Files

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,438

    Re: Problem with macro calculating on different data sets with different numbers of rows

    Change this:

    Please Login or Register  to view this content.

    To this:

    Please Login or Register  to view this content.


    The problem is that it's a different data set and there is no data in column C. You need to use a column with the maximum number of rows.


    Regards, TMS

  8. #8
    Registered User
    Join Date
    10-09-2012
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    82

    Re: Problem with macro calculating on different data sets with different numbers of rows

    excellent! that works really well. thank you for all your help!

  9. #9
    Registered User
    Join Date
    10-09-2012
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    82

    Re: Problem with macro calculating on different data sets with different numbers of rows

    just one last question, how would i get the sum of column L POC (EX VAT), again this would need to sum different number of rows.

    thanks

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,438

    Re: Problem with macro calculating on different data sets with different numbers of rows

    One way: =SUM(L:L)

    Regards, TMS

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,438

    Re: Problem with macro calculating on different data sets with different numbers of rows

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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