+ Reply to Thread
Results 1 to 5 of 5

Copy paste rows based on criteria

  1. #1
    Registered User
    Join Date
    01-25-2009
    Location
    Florida, USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Copy paste rows based on criteria

    I came across this code which copies the rows with a unique cell value from sheet1 and pastes these in sheet2.

    How can this be modified so that it pastes the new rows in sheet2 within a range.
    Range ("I20")
    ..another words, to offset the new rows from the cell I20 ?


    Any help to fix would be greatly appreciated!

    Please Login or Register  to view this content.

  2. #2
    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 rows based on criteria

    Hi,

    Maybe with

    Please Login or Register  to view this content.
    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.

  3. #3
    Registered User
    Join Date
    01-25-2009
    Location
    Florida, USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Copy paste rows based on criteria

    Thanks for the reply, Ricihard.

    I've tried to add your code .. and variations of this with no luck.


    Please Login or Register  to view this content.

    ..Also... , is there a way to change the paste functionality to insert. ?
    ie
    Selection.Insert Shift:=xlDown

    Thanks for all the help on this!

  4. #4
    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 rows based on criteria

    Hi,

    You seem to have added additional stuff to the code I gave you and it's by no means clear what you mean by paste 'within a range I20"

    You'd be better advised to upload the workbook and manually add the results you expect to see. I believe your code is far too complex for the simple task I think you're trying to achieve.

    Whenever you find yourself using a loop (For..Next, Do..Loop etc) to copy/delete or otherwise do stuff with specific cells / rows ask yourself if there isn't an easier way. In most cases there is and a simple data filter (either an AutoFilter or Advanced Filter) coupled with a .SpecialCells(xlCellTypeVisible).Copy instruction will do the job far more efficiently and with no more than a couple or so lines of code.

    Filtering is the fastest way of doing this stuff and avoids inefficient and slow looping procedures. This really should be a FAQ.

  5. #5
    Registered User
    Join Date
    01-25-2009
    Location
    Florida, USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Copy paste rows based on criteria

    Thanks Richard.

    I agree using the auto filter is very simple and efficient .. It's attempting to copy an entire row and paste/ offset from a specified range that gave me trouble...

    I've attached a simple file for you to possibly look at.

    Many thanks!
    Attached Files Attached Files

+ 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. [SOLVED] Copy/Paste rows based on certain criteria (drop down or colors)
    By jholiday78 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-26-2014, 08:15 PM
  2. [SOLVED] copy and paste rows based on criteria in column
    By CharlieZangel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-26-2013, 12:54 PM
  3. Copy and Paste Rows based on Criteria onto another sheet and sort based on oldest item
    By Kushal8684 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 05:37 AM
  4. [SOLVED] Macro to copy and paste rows to a new sheet based on criteria
    By Belo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-31-2010, 02:25 AM
  5. Copy\Paste multiple criteria based rows to new sheet
    By namz in forum Excel Programming / VBA / Macros
    Replies: 46
    Last Post: 06-06-2008, 08:08 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