Results 1 to 7 of 7

Macro Ending Early - When Using Range.Value on some macros?

Threaded View

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    USA
    MS-Off Ver
    2003, 2010, 2013, 2016
    Posts
    12

    Macro Ending Early - When Using Range.Value on some macros?

    For some reason my code is exiting early, and I really have no idea why. I'm triggering the PasteRangeMacro sub via the PasteDay1 sub (among others) and it's really annoying that the macro isn't finishing, among other reasons because the code doesn't re-enable events and reset the calculation status.
    It gives the "test0" debug print, and triggers the StartCell.Resize(DayRows,7).Value line, but does not trigger any of the following lines. I use Range.Value in other macros without this problem, so I'm stuck. Any ideas? Thank you so much.

    I'm using the latest version of Excel with a file format of .xlsm on a Windows 10 computer.

    Sub PasteRangeMacro(StartCell As Range)
        Application.EnableEvents = False
            
        If StoredCopyCell Is Nothing Then GoTo ErrorMessage
        OldCalculationMode = Application.Calculation
        Application.Calculation = xlCalculationManual
        Dim CopyStart As Range
        Set CopyStart = StoredCopyCell
        Debug.Print "test0"
        StartCell.Resize(DayRows, 7).Value = CopyStart.Resize(DayRows, 7).Value
        Debug.Print StartCell.Offset(0, 9).Resize(DayRows, 1).Address
        StartCell.Offset(0, 9).Resize(DayRows, 1).Value = CopyStart.Offset(0, 9).Resize(DayRows, 1).Value
        StartCell.Offset(0, 12).Resize(DayRows, 1).Value = CopyStart.Offset(0, 12).Resize(DayRows, 1).Value
        StartCell.Offset(0, 15).Resize(DayRows, 1).Value = CopyStart.Offset(0, 15).Resize(DayRows, 1).Value
        Debug.Print "test"
        Application.EnableEvents = True
        Application.Calculation = OldCalculationMode
        ActiveSheet.Calculate
        Exit Sub
     
    ErrorMessage:
        Application.EnableEvents = True
        MsgBox "Error - Please use a Copy button before pressing a Paste button."
    End Sub
    
    Sub PasteDay1()
        Dim StartCell As Range
        Set StartCell = Range("E5")
        Call PasteRangeMacro(StartCell)
    End Sub
    Last edited by bkm2016; 05-28-2017 at 04:41 PM. Reason: marking solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Ending Macro - Variable Range
    By Austex_egger in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2013, 02:52 PM
  2. Need help identifying a value range for ending a Loop Until
    By erik1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2013, 05:19 AM
  3. [SOLVED] Macro stops too early - Help!
    By cossie2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-25-2012, 10:15 AM
  4. Inserting text based on a predetermined criteria early in the macro
    By MonkeyFlyer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-30-2012, 06:06 PM
  5. determine begining row,col and ending row,col of variable range
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-17-2011, 08:09 PM
  6. Ending macro early
    By TedH in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-20-2009, 11:45 AM
  7. Ending Macros
    By lj123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-12-2008, 01:10 PM
  8. Ending a macro early conditionally on one cell being blank
    By Rokuro kubi in forum Excel General
    Replies: 3
    Last Post: 05-26-2006, 09:15 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