+ Reply to Thread
Results 1 to 7 of 7

Loop and copy

  1. #1
    Registered User
    Join Date
    10-15-2010
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    56

    Loop and copy

    I'm working on a loop and stuck, what I am trying to do is loop through a row A5:a43 and get data from B3:b43. THe data is picked form cell e3 & e4. What I want the loop to do is go down line A and when it finds the start date in e3 start to copy the adjacent rows and paste them in another row until the end date is reached which comes from e4.

    Please Login or Register  to view this content.
    Please let me know if you can help, I tried using the sumif formulas but it didn't work, and the sumproduct as well.. any help would be beneficial
    Attached Files Attached Files
    Last edited by gill389; 10-17-2010 at 05:22 PM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Loop and copy

    Please Login or Register  to view this content.



  3. #3
    Registered User
    Join Date
    10-15-2010
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Loop and copy

    Snb, thanks, I re-modified the Program a bit, your could is good, but I need to copy the adjacent cell. SO here is the new code im writing:


    Dim rngSource As Range
    Dim rngCell As Range
    Dim rngOnes As Range
    Dim rngTwos As Range
    Dim intOnes As Integer
    Dim intTwos As Integer

    Please Login or Register  to view this content.
    what I'm stuck on besides the loop is how to copy the adjacent cell when it finds "rangeones in Range?
    Last edited by gill389; 10-17-2010 at 05:22 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Loop and copy

    Hello gill389,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    NOTE: Other posters are not allowed to answer this post until you have complied with this request.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    10-15-2010
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Loop and copy

    I've made the adjustments you requested

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Loop and copy

    Hello gill389,

    Thank you for using the code tags.

  7. #7
    Registered User
    Join Date
    10-15-2010
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    56

    Question Re: Loop and copy

    I got a new code which goes in the right direction. It takes the start date in range E3, and then it goes into rangeb5 down until it finds X=which comes from E3 and goes to the adjacent cell and copies it and pastes it to D20.

    Where I am stuck: I need the loop to continue, so once the adjacent cell is copied, I need it to go back to Row A, go down 1, and copy the next adjacent cell paste it in d21 go back to A go down 1, copy the adjacent cell, copy into D22, and so on until the range e4 is reached where the user inputs the date.



    Please Login or Register  to view this content.
    Please let me know if you can help

+ 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