+ Reply to Thread
Results 1 to 28 of 28

Copy range based on specific criteria

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Copy range based on specific criteria

    Hello.
    In this workbook Orders Chart.xlsm i have an automatic code that runs a code called "Red", but for whatever reason the code "Red" is not working.
    I would like for the code to copy a range from the 1st tab based on specific criteria and paste it in the 2nd tab (see code below).

    Please Login or Register  to view this content.
    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy range based on specific criteria

    Please Login or Register  to view this content.
    What's LR?

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    I made a slight mistake.
    This part of the code
    Please Login or Register  to view this content.
    should be changed to
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    Hi John.
    LR is the last row.
    So PO_LR is the last row in worksheet "Orders"
    and EN_LR is the last row in worksheet "Easy Navigation"

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy range based on specific criteria

    Also:

    Please Login or Register  to view this content.
    I think these need a .row.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    The code will not reach this line
    Please Login or Register  to view this content.
    as LR is empty, so the code will not loop
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    Should be

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy range based on specific criteria

    Quote Originally Posted by kosherboy View Post
    Hi John.
    LR is the last row.
    So PO_LR is the last row in worksheet "Orders"
    and EN_LR is the last row in worksheet "Easy Navigation"
    You haven't defined an LR. You defined a PO_LR.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    This line is wrong too

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    I have two different LR and need to differentiate between them.
    I did some other modifications:
    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    Quote Originally Posted by AB33 View Post
    This line is wrong too

    Please Login or Register  to view this content.
    What should it be instead?

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    I do not know, but may be
    Please Login or Register  to view this content.
    .
    Few other errors.

    rCell.row.

    Can only use it on for each cell in range(Range collection), so remove the .row

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy range based on specific criteria

    You fixed that line, but you didn't fix these.

    Please Login or Register  to view this content.
    Oops. I completely misread the code. Post 12 is right.
    Last edited by JOHN H. DAVIS; 07-03-2014 at 03:21 PM.

  14. #14
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    I'm sorry guys but i'm a little confused, AB33 is saying i should remove the .row and John is saying i should include it??

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    Kosherboy,
    I do not know the purpose of the code, but you make it to appear more complicated than it should be.
    I have corrected some of the errors, but I do not know if it is a correct code.

    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy range based on specific criteria

    Maybe:

    Please Login or Register  to view this content.

  17. #17
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    AB33,
    I am trying to copy rangeA and rangeC from all rows in tab: "Orders" that are highlighted in red to tab: "Easy Navigation".
    Now, the reason why they are highlighted in red is because these orders were not placed yet, once i enter the date in column L the red disappears as this is based off conditional format. At my work we have thousands of orders to scroll through in the charts and sometime it gets overwhelming and we miss order here and there.
    Therefore i would like to dreate a "report" that would copy all the orders in red to the next tab.
    Here is what i want the next tab to look like Orders Chart.xlsm

  18. #18
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    Please Login or Register  to view this content.

  19. #19
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    AB33,
    Thank you for the response, most appreciated.
    However, i am getting an error message that reads "Out of stack space"?
    Last edited by kosherboy; 07-03-2014 at 04:30 PM.

  20. #20
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    It is probably because the event code is calling the Red code. Please remove the event code (Temporarily) and see if you are still get the error.

  21. #21
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    Ok! We are getting somewhere! Thanks
    A couple issues though:
    1) I only want The cell under column A and column C not A, B, C.
    2)The code is only pasting the last order that is in red, i need to have all the orders in red.

    Thank you and looking forward to hearing from you.....
    Last edited by kosherboy; 07-03-2014 at 04:39 PM.

  22. #22
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    Use this line

    Please Login or Register  to view this content.
    Instead of

    Please Login or Register  to view this content.
    .

    I am not sure by request 2. What do you mean?
    Last edited by AB33; 07-03-2014 at 04:51 PM.

  23. #23
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    There are roughly 23 rows on the 1st tab that are in red. (The reason they are in red is because column L = nothing)
    I would like for the macro to copy column A and C of all the 23 rows onto the 2nd tab.

  24. #24
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    There are roughly 23 rows on the 1st tab that are in red. (The reason they are in red is because column L = nothing)
    I would like for the macro to copy column A and C of all the 23 rows onto the 2nd tab.

  25. #25
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    This is the condition for copying

    Please Login or Register  to view this content.
    Both have to be true for the code to copy A and C. That is column A has to be not empty while at the same time column L has to be empty. Please look at your data

  26. #26
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    Precisely, all the rows in red are not empty in column A and at the same time are empty in column L. So all 23 rows should be subjected to get copied. No?

  27. #27
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy range based on specific criteria

    Sorry! I did not notice that the next empty rows in destination sheet were wrong.

    Please Login or Register  to view this content.

  28. #28
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Copy range based on specific criteria

    You did it!
    Thanks a billion!

+ 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. Need VBA help to filter and copy data based on specific criteria
    By astrial in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-13-2013, 10:48 AM
  2. [SOLVED] Copy data to specific range in another Book based on conditional criteria
    By khatibcell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2013, 02:39 AM
  3. HELP! Macro to Copy specific cells from one sheet to another based on specific criteria
    By atriscritti in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-11-2012, 11:05 AM
  4. [SOLVED] Counting Occurences in a Range based on Specific Criteria
    By artikyulashun in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-24-2012, 12:23 PM
  5. VBA to copy data into other sheets based on specific criteria’s
    By humacdeep in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 01-31-2012, 09:12 AM

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