Results 1 to 6 of 6

If a Macro is executing, then deactivate Sheet 'Private Sub' code ? Is this possible ?

Threaded View

  1. #1
    Registered User
    Join Date
    01-14-2015
    Location
    Beja, Portugal
    MS-Off Ver
    2013
    Posts
    7

    Question If a Macro is executing, then deactivate Sheet 'Private Sub' code ? Is this possible ?

    So i have the following problem here.
    I'm trying to create a Macro in which a new Row is created, and at the same time the previous Row's information is respectively copied from Sheet A (Main information) to Sheet B (Summary of Sheet A info). The problem i'm having is, because the document is so packed with formulas, calculations and macros, leaving calculation mode in "Automatic" looses me a lot of time for every little cell i change, so i set it to "Manual", and in each different sheet i put in the following code:

    Private Sub Worksheet_activate()
    
    ActiveSheet.Calculate
    
    End Sub
    So the results only update with each time you change Sheets... The problem with this is, the previous macro i made gets interrupted by this one while copying info from Sheet A to B, which makes perfect sense. What i would like to know is, is there anyway i can edit this code so that while other Macros are executing, this one is ignored ???

    Here is the code for the Macro in Sheet A for further analysis if you need:

    Sub MEN01Obra()
    '
    ' MEN01Obra Macro
    '
    
    '
        If Len(Range("C10").Value) = 0 Then Exit Sub
        Application.ScreenUpdating = False
        Application.Calculation = xlManual
         Rows("9:9").Select
        Selection.EntireRow.Hidden = True
        Rows("10:10").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("H11").Select
        Selection.AutoFill Destination:=Range("H10:H11"), Type:=xlFillDefault
        Range("H10:H11").Select
            Range("O11:T11").Select
        Selection.AutoFill Destination:=Range("O10:T11"), Type:=xlFillDefault
        Range("O10:T11").Select
        Range("V11").Select
        Selection.AutoFill Destination:=Range("V10:V11"), Type:=xlFillDefault
        Range("V10:V11").Select
            Range("Y11:Z11").Select
        Selection.AutoFill Destination:=Range("Y10:Z11"), Type:=xlFillDefault
        Range("Y10:Z11").Select
        Range("AB11:AC11").Select
        Selection.AutoFill Destination:=Range("AB10:AC11"), Type:=xlFillDefault
        Range("AB10:AC11").Select
        
        Range("B1").Select
        Selection.Copy
        Range("A10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("b10").Select
        
        'Go to Sheet B to copy info
        Sheets("Sheet B").Select
        Rows("10:10").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("B10").Select
        Sheets("Sheet A").Select
        Range("A10").Select
        Selection.Copy
        Sheets("Sheet B").Select
        Range("B10").Select
        ActiveSheet.Paste
        Range("C11:I11").Select
        Application.CutCopyMode = False
        Selection.AutoFill Destination:=Range("C10:I11"), Type:=xlFillDefault
        Range("C10:I11").Select
        Range("B11").Select
        Selection.Copy
        Range("B10").Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
        Sheets("Obras").Select
        
        Range("B10").Select
        Application.ScreenUpdating = True
    End Sub
    - The red text is what's highlighted in Debug when the code breaks...

    All helps is appreciated
    Last edited by jcabroxo; 01-14-2015 at 11:42 AM. Reason: SOLVED

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Deactivate a private sub
    By Jeckford in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2014, 10:58 PM
  2. Module Subs executing Private Subs without prompt by code - Totally Lost
    By Ozan Ertem in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-26-2012, 05:31 PM
  3. [SOLVED] Active sheet shifts back to original sheet when executing code
    By pcdog in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-22-2012, 11:07 AM
  4. Too many calculations preventing Private Sub from executing macro
    By tx12345 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2006, 04:43 PM
  5. Trouble with Sheet Deactivate macro
    By CLR in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-19-2005, 11:05 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