+ Reply to Thread
Results 1 to 4 of 4

Copy/Paste 30 Times or Loop?

  1. #1
    Registered User
    Join Date
    12-09-2008
    Location
    Canada
    Posts
    79

    Copy/Paste 30 Times or Loop?

    Hi guys, I've attached below a small part of my code. I am wondering if there is a way to do this, without copying and pasting something 30 times, but using a loop instead.

    As you can see there are a series of productsNumbers (30 in total, but this example is for 3). Each productNumber is a string that is actually a 5 digit number, so it can be an integer as well, if it has to.

    I would like to code below to loop for as many products as there may be. The way that I have it right now does not work - I feel that I am missing something small or that there is no way to do this. Suggestions are apperciated. Thanks!

    Please Login or Register  to view this content.
    Last edited by GeorgY; 11-18-2009 at 12:33 PM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Copy/Paste 30 Times or Loop?

    Oh my, yes there are a few improvements...

    Why not just use autofilter?

    Also, post an example.
    CC

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Copy/Paste 30 Times or Loop?

    Hi,

    It seems you've already got the guts of your loop. If I've understood correctly, delete the productnumber1, productnumber2 etc. variables.

    Make the loop counter(assuming the product numbers are in a contiguous range),

    Please Login or Register  to view this content.
    Then in the For Each Cell..Next cell loop

    Please Login or Register  to view this content.
    What's the object of the code? There may be a simpler way of solving your requirement, perhaps a pivot table???

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    12-09-2008
    Location
    Canada
    Posts
    79

    Re: Copy/Paste 30 Times or Loop?

    Thanks Richard, that was exactly what I was looking for.

    Yes, it's currently being done by pivot table. I like code more.

+ 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