+ Reply to Thread
Results 1 to 3 of 3

Copy Paste LOOP when condition is met

  1. #1
    Registered User
    Join Date
    07-18-2019
    Location
    Brno
    MS-Off Ver
    2013
    Posts
    1

    Copy Paste LOOP when condition is met

    Hello guys,

    I have been trying to find the solution for this but I still cannot get it right, please help as my head is about to explode now, really.

    In attached file and screenshot I am trying to achieve that when user clicks on invoice number and hits the LoopClick button, macro copies all the raws that are within the same customer and stops once this is done for one customer.

    Lets say user clicks on invoice number 11201686 and hits the button, macro starts copying all the lines from A.M. Marketing customer and stops once all the lines are copied to sheet HideLater2 one by one.

    I must have tried almost all of the loop functions but the further I got was that I can loop through until the last raw of, lets say, A.M. Marketing but looping does not copy the last line because of the offset setting that I just have not right, i dont know.

    I was trying to make looping work first and then applying the copy/paste functions so you will see that it loops and does some bullshit but this is just because I could not get through the first stage - getting the loop right and the rest of the code is copied from some web.


    Is there please someone who could help me? It must be something easy, some while loop or until loop and it just must stop once all the customer invoice lines are copied. I just cannot get this right.

    Thank you very much!!!



    Code:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by AliGW; 07-18-2019 at 12:35 PM. Reason: Irrelevant section of title removed.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Copy Paste LOOP when condition is met

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. 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, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, 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

    (Note: this change is not optional. As you are new, I've done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy Paste LOOP when condition is met

    Hello MarkS419

    I am trying to achieve that when user clicks on invoice number and hits the LoopClick button, macro copies all the raws that are within the same customer and stops once this is done for one customer.
    Have no idea what your posted code has to do with this...

    You did not mention whether sheet5 has already got the Headings...Or what columns should be copied over...Or whether you want code to check if customer details are already present...

    Please Login or Register  to view this content.
    Last edited by sintek; 08-18-2019 at 08:23 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ 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. How to use a For Loop to copy and paste to another sheet based on condition?
    By maym in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-15-2018, 10:31 PM
  2. loop through & copy based on condition
    By cds1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2018, 07:19 AM
  3. Replies: 1
    Last Post: 01-21-2016, 06:05 PM
  4. [SOLVED] Copy Paste Loop ends before copy/paste is finished
    By brgr4u in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-08-2013, 04:01 PM
  5. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  6. Copy/Paste based on encountered condition within a loop
    By msmick in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2011, 06:37 PM
  7. Copy and Paste Rows For certain condition then loop
    By steve70070 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2011, 06:05 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