+ Reply to Thread
Results 1 to 9 of 9

How To Loop a copy range macro until lookup cell is blank/empty

  1. #1
    Registered User
    Join Date
    07-12-2013
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007 & MAC excel 2011
    Posts
    51

    How To Loop a copy range macro until lookup cell is blank/empty

    Hello, I have a 2 Macros that looks to see if a cell (i2) has info and if it does, it copies a range 057:AX57 to O2 when I click a button, which works, now what I would like to do it the macro then looks at i3, i4... and then copies the same range but next row down (O3) and loops until it hits a blank cell in "i", below is my current code, just not sure how to make it loop.


    Please Login or Register  to view this content.
    Any assistance would be greatly appreciated.
    Last edited by iggypop; 11-01-2017 at 09:40 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,687

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    07-12-2013
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007 & MAC excel 2011
    Posts
    51

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    Thank you Alan, corrected:

    Ok, I have resolved the loop issue, but based on the code below how do I paste values only not formula, I have found and tried the pastespecial xlPasteValues but not sure how to properly use in my code since it keeps giving me errors.

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,687

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    I am assuming that this is the sub you wish to modify. See if this works for you

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-12-2013
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007 & MAC excel 2011
    Posts
    51

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    Excellent, thank you Alan, that did the trick but created another minor prob. the 2nd col in my range (q2 - line items) does need the formula copied because the formula causes it auto loop (i.e. 1,2,3...). with this fix, line item is always 1.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,687

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    Suggest you upload a sample worksheet and explain your issue using the worksheet. Having difficulty visioning. Old eyes see things clearer when presented in a viewable format.

  7. #7
    Registered User
    Join Date
    07-12-2013
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007 & MAC excel 2011
    Posts
    51

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    Thank Alan, no need, got it to work, appreciate your assistance. Hopefully one last question. I am able to copy just the values to clipboard, and on the Output spreadsheet 1 column of cells have a data validation drop down list setup, now if I right click and paste values, the data validation is not over ridden but if I just CTRL V, they are over ridden, any idea around this, my concern is if I am not the one doing the paste it may not be done right.
    Last edited by iggypop; 11-02-2017 at 08:51 AM.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,687

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    Do you have a macro associated with Ctl + P because that was a standard keyboard shortcut to Print.

  9. #9
    Registered User
    Join Date
    07-12-2013
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007 & MAC excel 2011
    Posts
    51

    Re: How To Loop a copy range macro until lookup cell is blank/empty

    No Macro, just using keyboard shortcut or right mouse click, issue is the output workbook is our data and we do not want to setup macros or vba (if possible), just the data.
    Last edited by iggypop; 11-02-2017 at 03:51 PM.

+ 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. [SOLVED] Loop copy cell of range to 1 cell, and so on till cell empty
    By countryfan_nt in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2017, 02:33 AM
  2. Replies: 3
    Last Post: 01-09-2017, 05:22 PM
  3. VBA macro to copy last non blank cell on a certain range that has formula
    By danwoltrs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2016, 03:58 PM
  4. [SOLVED] How to copy into next empty row using "for each cell in range" loop
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2013, 02:30 PM
  5. [SOLVED] Excel VBA macro to select range separated by blank row and copy to next empty column
    By hackini in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2013, 02:13 AM
  6. [SOLVED] Returning a blank cell if the lookup value is empty
    By mgmerv in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-02-2012, 06:59 AM
  7. Macro Copy Active Cell to Range Name, loop
    By zigstick in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-27-2005, 03:06 PM

Tags for this Thread

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