+ Reply to Thread
Results 1 to 14 of 14

Populate data until specific row criteria is reached.

  1. #1
    Registered User
    Join Date
    03-26-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Populate data until specific row criteria is reached.

    Hello,

    I am trying to edit a VBA module so that it populates data from one sheet to another but only until a specific row is reached.

    For example, I have table with a column that contains various dollar amounts and a row at the bottom labeled TOTALS that sums that entire column. But, when I run the macro I only want it to copy the values above the total amount. I do not want it to include the actual total amount. Is this possible?

    Thank you for your help!

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Populate data until specific row criteria is reached.

    Hi Ollander88,


    Welcome to the forum.

    yes this is achievable.. you can have include something like below in your code:-

    Please Login or Register  to view this content.
    would suggest you to the post the sample file with code to help you better. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: Populate data until specific row criteria is reached.

    The code looks like this

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-26-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Populate data until specific row criteria is reached.

    Thank you for all your responses. I guess I should have included the original code. How would I incorporate it into the following:
    Please Login or Register  to view this content.
    Thank you!
    Last edited by Paul; 03-27-2012 at 01:40 AM. Reason: Added CODE tags for new user. Please do this yourself in the future.

  5. #5
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Populate data until specific row criteria is reached.

    Hi Dennis7849,


    Could you post the file containing this code... thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  6. #6
    Registered User
    Join Date
    03-26-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Populate data until specific row criteria is reached.

    DILIPandey,

    When I tried to incorporate your code, the data continue to copy itself continuesly. This is the code I am working with.
    Please Login or Register  to view this content.
    Last edited by Paul; 03-27-2012 at 01:40 AM. Reason: Added CODE tags for new user. Please do this yourself in the future.

  7. #7
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Populate data until specific row criteria is reached.

    Hi Ollander,

    Replace line 3 of your code with following. thanks

    Please Login or Register  to view this content.
    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  8. #8
    Registered User
    Join Date
    03-26-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Populate data until specific row criteria is reached.

    DILIPandey,

    That doesn't seem to work. Attached is the excel file.
    Attached Files Attached Files
    Last edited by Paul; 03-27-2012 at 01:41 AM. Reason: Removed quote of full previous post. Unnecessary clutter.

  9. #9
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Populate data until specific row criteria is reached.

    Hi Ollander,


    See the attached file and let me know if the macro works fine. thanks.

    Regards,
    DILIPande

    <click on below 'star' if this helps>
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-26-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Populate data until specific row criteria is reached.

    DILIPandey,

    That code works fine; although the range is fixed. I would like it to be dynamic as there is the possibility of the data exceeding a fixed range of rows. Hence why I asked if it would be possible to have the data stop populating once it reaches the row that contains the text "Totals" in it. Is that still possible? I appreciate your help.

  11. #11
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Populate data until specific row criteria is reached.

    Hi ollander88,

    See the revised solution.
    Now it will copy the range till the Totals.. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    Attached Files Attached Files

  12. #12
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Populate data until specific row criteria is reached.

    Ollander,

    In the future please be sure to wrap your code within [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags. Also, don't quote entire posts as it just clutters the thread.

    Thank you.

  13. #13
    Registered User
    Join Date
    03-26-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Populate data until specific row criteria is reached.

    When I run the macro, the 'Run-time error 1004 Application-defined or object definer error' dialog box appears.

  14. #14
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Populate data until specific row criteria is reached.

    Hi ollander88,

    Macro is running fine on my system.

    Can you run it in break mode and share the outcome.. Alt+F11, go to the code, press F8 and again and again.. see the outcome and let me know where it has given error. thanks.


    Regards,
    DILIPandey

    <click on below 'star' if this helps>

+ 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