+ Reply to Thread
Results 1 to 7 of 7

VBA Code to Select Multiple Rows and Copy

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    VBA Code to Select Multiple Rows and Copy

    Hi,

    Please see below code:


    Please Login or Register  to view this content.
    This will run through each row and if the criteria met will copy that row to another tab and so on until all rows are scanned. Unfortunately its very slow. Is there a way to select all the rows that meet the criteria (a Ctrl + select method) and after all cells selected copy the data over as a whole thus saving time?

    Any help is greatly apprecaiated.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code to Select Multiple Rows and Copy

    Try this
    Please Login or Register  to view this content.
    Change the parts marked bold.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: VBA Code to Select Multiple Rows and Copy

    Thanks for the comment
    The issue lies with the amount of rows that excel can action the 'visible cells only' command (which I tried to use but I got an error stating the action is too complex).

    The reason I ask for the method stated in the earlier post is to counteract this problem. Any suggestions welcome?

  4. #4
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: VBA Code to Select Multiple Rows and Copy

    Just to note, I have in excess of 260,000 rows in the worksheet

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code to Select Multiple Rows and Copy

    Is it fine to sort the data? You can sort the data based on the column and so all the 1, 2 and 3 will appear on top. This way, the macro will work faster. We can ask the macro to stop once it reaches a value >3.

    Do you want a code to do this?

  6. #6
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: VBA Code to Select Multiple Rows and Copy

    Thats a great idea.

    The sorting part can be completed manually. I don't mind that but for the remaining code I presume I just write:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code to Select Multiple Rows and Copy

    Yes, there are many ways of doing it. You can try whichever way you are comfortable in. If you face any issues, you can post it back here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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