+ Reply to Thread
Results 1 to 4 of 4

VBA Copy and Paste Code works once, then stops working?

  1. #1
    Registered User
    Join Date
    08-25-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    36

    VBA Copy and Paste Code works once, then stops working?

    Hi

    I hope you can help.

    I use a spreadsheet where standard data is input on a tab daily basis. Monday to Sunday.

    At the end of the week we then copy and paste the data on to one main sheet so we can review the data as a whole.

    I have some VBA knowledge so I wrote the following code and assigned it to a button to get it to work in one press. Thing is it works once, and then disables all copy and paste functions in the whole sheet. I cannot think why this code would disable all copy and paste in the sheet. Please have a look at the code and see if you can see anything I have missed.

    'Copy specific range of data regardless of what is contained within
    Sub MasterCopy()
    Sheets("Monday").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    Sheets("Tuesday").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    Sheets("Wednesday").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    Sheets("Thursday").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    Sheets("Friday").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    Sheets("Saturday").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    Sheets("Sunday").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    Sheets("B2B").Range("A4:AZ500").Copy Destination:=ActiveSheet.Cells(65000, 1).End(xlUp).Offset(1, 0)
    MsgBox "Copied All Days Data", vbOKOnly + vbInformation
    End Sub

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: VBA Copy and Paste Code works once, then stops working?

    Try disabling events at the start and re-enabling them at the end of your code. Sometimes large copy/paste can cause issues so turning off events can save a fair bit of hassle.
    If someone has helped you then please add to their Reputation

  3. #3
    Registered User
    Join Date
    09-16-2017
    Location
    Agra
    MS-Off Ver
    2013
    Posts
    72

    Re: VBA Copy and Paste Code works once, then stops working?

    Dear ZEROCOOL,

    It looks perfectly Fine . Try as pjwhitefiled has recommended. Also try below ( not a direct relation to your problem but sometime weird problems have weird solutions. )

    Use in the beginning of your code after declaring sub -- "Application.screenupdating = False "
    Use at the end of your code -- "Application.screenupdating = True"

  4. #4
    Registered User
    Join Date
    08-25-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    36

    Re: VBA Copy and Paste Code works once, then stops working?

    Hi

    Thanks for the advice, it turns out a rouge line of data on row 13000 was the issue, no idea how it got there.

    The code looks for for lowest line of data and place the copied item there, I had a lot of data from row 13000 down.

    Very strange, but fixed now.

    Thank you for taking the time to look, rep has been added.

+ 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] Code to Copy Excel to Word stopped working in 365 but still works on 2010
    By JimmyA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2018, 04:46 AM
  2. Find last row, copy, paste works but a little help with cleaning up the code
    By pasqui83 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-23-2017, 12:59 PM
  3. [SOLVED] Code stops working
    By Excelski in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-27-2017, 12:23 PM
  4. [SOLVED] formula stops working after I copy/paste
    By scudo in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 05-03-2015, 04:57 PM
  5. SSN Format Code Works... Then stops working?
    By sgtclaire in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2013, 09:43 AM
  6. Excel paste special stops the sheet from working
    By hazzaska in forum Excel General
    Replies: 3
    Last Post: 01-08-2013, 09:11 PM
  7. VB Code stops working
    By Michelle K in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-28-2005, 05:06 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