+ Reply to Thread
Results 1 to 2 of 2

Macro Runs IN Debug but Not In Automatic

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2015
    Location
    Huddersfield UK
    MS-Off Ver
    2013
    Posts
    1

    Macro Runs IN Debug but Not In Automatic

    Hi All,

    I'm wondering if someone can help me. I must admit I have been using these forums for awhile as a guest and been searching for answers instead of posting but could not find anything to solve this.

    I have recently written a VBA procedure that activates upon open then goes off to a google drive and opens a file to check against the value in Cell A1. The filename of the file being checked contains the revision number and the check is to ensure a user is using the correct file revision.

    In Debug mode the macro works perfectly but in auto mode it crashes after open event from Google with the error code execution has been interrupted. I've tried adding pauses and do loops but to no avail.

    Anyone have any suggestions?

    Many thanks in advance,
    Steve

    Private Sub RevCheck()
    
    Dim FileRev As String
    Dim RevCheck As String
    
    'Selects destination cell for filename and adds current filename to cell
    Range("A15").Select
    ActiveCell.FormulaR1C1 = "=cell(""filename"",R1C1)"
    
    'Opens file from google drive and copies cell contents
    
    Workbooks.Open ("https://docs.google.com/uc?export=download&id=0B08sDakjUp91azZhUVhmdThxUDQ&authuser=0")
    
    ' Macro Fails here when in autorun mode. It works when you step through with F8
    
    Range("a1").Select
    Range("a1").Copy
    ActiveWorkbook.Close
    
    
    'Activates source code workbook
    ThisWorkbook.Activate
    
    'Pastes check value from Connect file
    Range("a16").PasteSpecial
    
    'identifies variables
    FileRev = Range("A15")
    RevCheck = Range("A16")
    
    'Performs checks and excecutes accordingly
    If InStr(1, FileRev, RevCheck) > 0 Then
    MsgBox ("You are using the correct revision of the Autoupload Sheet." & vbNewLine & vbNewLine & "Please continue to complete your upload.")
    Else
    MsgBox ("You are not using the latest revision of the Autoupload Sheet" & vbNewLine & vbNewLine & "Please download the latest revision from the SEDMS Team Room" & vbNewLine & vbNewLine & "The file will now close.")
    ThisWorkbook.Saved = True
    ThisWorkbook.Close
    
    
    End If
    
    
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Macro Runs IN Debug but Not In Automatic

    Hi SteWilf
    I would think it's because the way you're getting the data from the worksheets etc. You're activating & selecting worksheet/cells etc, so the workbook/worksheet you're wanting to read isn't active

+ 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. Need help with debug issue with macro
    By Lylestyle89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2015, 01:36 PM
  2. VBA Code Runs in Debug Mode But Returns Type Mismatch Error Outside Debug Mode
    By valerie.k.chiang in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2014, 03:48 PM
  3. [SOLVED] Code skips on Run Mode but runs fine on F8 (Debug Mode)
    By RaquelAR in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-25-2013, 01:05 PM
  4. Replies: 3
    Last Post: 03-29-2012, 01:58 PM
  5. Macro Runs fine in debug but not from ComboBox
    By jaslake in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-25-2009, 10:17 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