+ Reply to Thread
Results 1 to 4 of 4

Any idea to make this code work faster ( copy and paste data )

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Any idea to make this code work faster ( copy and paste data )

    hi,
    i am using this code to copy data and paste another sheet
    but its working very slowly, please any idea to make this faster code

    Please Login or Register  to view this content.
    Use Code-Tags for showing your code :
    Please mark your question Solved if there has been offered a solution that works fine for you
    If You like solutions provided by anyone, feel free to add reputation using STAR *

  2. #2
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Any idea to make this code work faster ( copy and paste data )

    setting the screenupdating to false at the beginning and then reversing it at the end
    in the beginning of the code
    Please Login or Register  to view this content.
    you may also set the calculation to manuall at the beginning and the to automatic in similar fassion if your sheet is full of formulas that are calculated after every operation.
    at the end of the code before end sub key word

    Please Login or Register  to view this content.
    Teach me Excel VBA

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Any idea to make this code work faster ( copy and paste data )

    One of the reasons your code is running slowly is that you are copying and pasting several columns separately and repeating the same process many times
    Copy/Paste copies only filtered rows - so I have not included specialcells in the code

    Instead of copying and pasting in bits
    - firstly copy and paste the whole of the data values range to a temporary sheet
    - then instead of copying and pasting each column, attribute the values instead

    I am guessing that you have filter headers in row 7 and that you are copying all your filtered data range - if not
    replace this in the code below
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    and the Resize becomes Resize(lr) instead of Resize(lr - 1)


    Create a temporary sheet and name it "Temp" and try replacing everything in your code below line On Error Resume Next (which you should no longer require)
    Please Login or Register  to view this content.

    And do not forget to include ImranBhatti's suggestions - which avoid the sheet being recalculated and the display refreshed every time a value is changed by VBA
    Last edited by kev_; 04-25-2017 at 03:46 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Any idea to make this code work faster ( copy and paste data )

    This will not make much difference to speed but by adding a variable, the code can be simplified on the 7 rows where the values are being attributed

    create variable to find the next row
    Please Login or Register  to view this content.
    then
    Please Login or Register  to view this content.
    is simplified to
    Please Login or Register  to view this content.
    Last edited by kev_; 04-25-2017 at 03:35 AM.

+ 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. Combine four codes with one code to make work faster
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2017, 11:40 AM
  2. Any idea to make code faster
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-28-2017, 07:46 PM
  3. [SOLVED] Anz idea how to make this code work in 2007
    By jj4jj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-27-2016, 06:33 AM
  4. Make the below code work faster!!!
    By devpp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2013, 06:13 AM
  5. How can I make this copy paste function faster???
    By just_helping in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2012, 11:49 AM
  6. Replies: 2
    Last Post: 11-15-2010, 02:07 AM
  7. Can anyone optimize the code? (to make it work faster)
    By olegai in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-23-2007, 07:50 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