+ Reply to Thread
Results 1 to 2 of 2

Copy and paste is very slow to do work

Hybrid View

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

    Post Copy and paste is very slow to do work

    hi,
    this is working ok but very slow to do work, need help to improve speed of this code

    thank you

    Sub COPY_DITTO_FINAL()
    Application.ScreenUpdating = False
    If ActiveSheet.Name = "OL BC" Then
    Dim NextRow As Range
    Set NextRow = Sheet5.Cells(Cells.Rows.Count, 1).End(xlUp).Offset(1, 0)
    Sheet5.Cells(Cells.Rows.Count, 1).End(xlUp).Offset(0, 0).EntireRow.Copy
    NextRow.PasteSpecial ' (xlValues)
    Sheet5.Cells(Cells.Rows.Count, 1).End(xlUp).Offset(0, 6).Value = 1
    Range("H10").End(xlDown).Offset(0, 0).Select
    Else: End If
    Application.ScreenUpdating = True
    End Sub
    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
    Registered User
    Join Date
    10-07-2017
    Location
    Perth, Down Under
    MS-Off Ver
    2016
    Posts
    45

    Re: Copy and paste is very slow to do work

    Hi HaroonSid

    I suspect if you have formulas in the row then using Offset could be the culprit because it will cause the wsheet to recalculate. Also I find copying entire rows or columns can be very slow so try to limit the number of columns by finding the last real column used.
    Try this:

    Sub COPY_DITTO_FINAL()
    
        With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        
        If ActiveSheet.Name = "OL BC" Then
        
            Dim nLastRow As Long
            Dim nLastColumn As Long
        
            With Sheets(5)
            ' find last row and last column
                nLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
                nLastColumn = .Cells.Find("*", .Cells(1), xlFormulas, xlPart, xlByColumns, xlPrevious).Column
                
                'copy paste to next row
                .Range(.Cells(nLastRow, "A"), .Cells(nLastRow, nLastColumn)).Copy .Cells(nLastRow + 1, "A") 
       
    'NOTE:if you need to use PasteSpecial then delete the line above
    'and use these next 2 lines
    '.Range(.Cells(nLastRow, "A"), .Cells(nLastRow, nLastColumn)).Copy
    '.Cells(nLastRow + 1, "A") .PasteSpecial xlPasteAll
                
                'insert value to "F" new last row
                .Cells(nLastRow + 1, "F") = 1
                
                Range("H10").End(xlDown).Select
                
            End With
            
        Else: End If
    
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        End With
        
    End Sub
    hth
    Last edited by Ozex; 10-14-2017 at 08:43 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. [SOLVED] Worksheet Change Event Is very Slow To work copy formula and paste
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-07-2017, 07:12 AM
  2. [SOLVED] Slow Copy and Paste
    By DukeRondo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2014, 07:40 PM
  3. [SOLVED] Slow Copy And Paste
    By Pierce Quality in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-20-2014, 05:10 PM
  4. Copy/paste macro is running slow
    By Kaplan275 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2012, 08:28 AM
  5. Excel copy/paste slow
    By plunk25 in forum Excel General
    Replies: 2
    Last Post: 06-12-2006, 10:10 PM
  6. [SOLVED] copy and paste very slow
    By Alan in forum Excel General
    Replies: 2
    Last Post: 08-05-2005, 05:05 PM

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