+ Reply to Thread
Results 1 to 10 of 10

VBA Code is running really slowly

Hybrid View

  1. #1
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: VBA Code is running really slowly

    Maybe something along the lines of:

    Sub KittenExplosion()
    
    Application.EnableEvents = False
    application.Calculation =xlCalculationManual
    
    'copying and pasting stuff
    
    Application.EnableEvents = True
    application.Calculation =xlCalculationAutomatic
    
    End Sub
    This will prevent the workbook from calculating formula outputs or running additional subs while the macro is running.


    Edit: I found an additional solution on the interwebs.

    Delcare a global variable at the top of your module, and set it to on while the macro runs. Worksheet_Change event can see if it's on, and stop if it is.

    Public CopyRunning As String
    Sub CopyPasteMacro() 
        CopyRunning = "On" 
    
        'copy and paste stuff 
    
        CopyRunning = "Off" 
    End Sub
    and then worksheet_change macro:
    Private Sub Worksheet_Change(ByVal Target As Range) 
        If CopyRunning = "On" Then Exit Sub 
    
        'normal code stuff
    End Sub
    Last edited by daffodil11; 06-05-2014 at 05:20 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

+ 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. Code running really slowly
    By The Phil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-03-2014, 08:42 PM
  2. [SOLVED] Code running slowly
    By Sweepin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 09:15 PM
  3. [SOLVED] Code running slowly any way of speeding up processing time
    By boomboomblock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2013, 09:09 AM
  4. Code running slowly
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 02-01-2011, 11:08 AM
  5. Paste code running extremely slowly...
    By KR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2005, 11:05 AM

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