+ Reply to Thread
Results 1 to 4 of 4

HELP copying multiple ranges per row based on cell criteria using a Loop

  1. #1
    Registered User
    Join Date
    11-03-2010
    Location
    Costa Mesa, California
    MS-Off Ver
    Excel 2003
    Posts
    28

    HELP copying multiple ranges per row based on cell criteria using a Loop

    Hello,

    I have been struggling to find a means of identifying rows of data based on their cell value in column "J" (RequestID), and then copying certain ranges in the target rows to copy to another sheet.

    In the attached example, I am trying to identify each row in Sheet1 that has an REQ number in column "J".
    If column "J" has an REQ number, then I want to copy that row's cells in columns A:E and H:I to Sheet2 and then loop through the rest of the rows that have an REQ number and do the same.

    By the end of the macro, Sheet2 would show a list of cell data from columns A:D and H:I for each row that had an REQ number in column "J" on Sheet1 and have stripped out formatting so it is just text.

    I have put an example of what the final product would hopefully look like on Sheet3.

    Thanks so much in advance for your help!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: HELP copying multiple ranges per row based on cell criteria using a Loop

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    11-03-2010
    Location
    Costa Mesa, California
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: HELP copying multiple ranges per row based on cell criteria using a Loop

    AlphaFrog - Thanks for the quick reply! I have certainly learned by looking at your code - the range line in particular is what I was struggling with the most. Would you mind sharing what the "- 1" does after the ".Rows.Count" parts of the range definition?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: HELP copying multiple ranges per row based on cell criteria using a Loop

    You're welcome.

    My mistake. The -1 is a remnant from another method (.resize) I started to use to define the range.

    The line of code should be...
    .Range("A2:E" & .Rows.Count & ",H2:I" & .Rows.Count).Copy
    Last edited by AlphaFrog; 10-28-2016 at 01:35 PM. Reason: typo

+ 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. Adding multiple sheets based on defined ranges/criteria
    By ronaldev in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-17-2015, 05:59 AM
  2. Replies: 8
    Last Post: 07-09-2014, 10:42 PM
  3. [SOLVED] Summing multiple ranges based on criteria....
    By Barking_Mad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-26-2014, 06:42 AM
  4. [SOLVED] vba copy and paste based on multiple loop criteria
    By sarahcpa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-19-2013, 10:29 AM
  5. Add up multiple ranges of data based on criteria.
    By wtmh in forum Excel General
    Replies: 5
    Last Post: 12-17-2009, 04:17 AM
  6. sum the values of a range based upon multiple ranges and criteria
    By LiveIt... in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-17-2006, 04:23 PM
  7. Loop through cells and add rows based on multiple criteria
    By Northern Hybrid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2005, 06:39 AM

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