+ Reply to Thread
Results 1 to 3 of 3

VBA Step Into works as desired but running macro doesn't

Hybrid View

smit.etha VBA Step Into works as... 09-16-2015, 07:24 PM
LJMetzger Re: VBA Step Into works as... 09-16-2015, 07:44 PM
MarvinP Re: VBA Step Into works as... 09-16-2015, 07:47 PM
  1. #1
    Registered User
    Join Date
    02-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    28

    VBA Step Into works as desired but running macro doesn't

    Title says it all. Stepping through the below code does as desire but running the macro doesn't. I am specifically having issues with the Else portion. This is what happens when I run the macro

    CountA(Range("B2:B5")) currently equals 3 so goes to Else
    Excel pauses for 5 seconds
    then image "Dennis" flashes and disappears.

    Running in step through (This is what I want)
    CountA(Range("B2:B5")) currently equals 3 so goes to Else
    Image "Dennis" appears
    Excel pauses for 5 seconds
    Image "Dennis" disappears
    End

    Thoughts?
    Private Sub Image1_Click()
    
        Application.ScreenUpdating = True
        
        If Application.WorksheetFunction.CountA(Range("B2:B5")) = 4 Then
            
        ActiveSheet.PageSetup.LeftFooter = Format(Now, "yyyy.mmm.dd HH:MM")
    
        Sheets("Temp Logger|GPS Setup").Select
      
        ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\Ethan\Desktop\" & Sheets("Temp Logger|GPS Setup").Range("A1") & ".pdf", Quality:=xlQualityStandard,     IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
          
        Else
        
        Shapes("Dennis").Visible = msoTrue
        
        Application.Wait (Now + TimeValue("00:00:05"))
          
        Shapes("Dennis").Visible = msoFalse
            
        End If
        
    End Sub
    Last edited by Leith Ross; 09-16-2015 at 07:41 PM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: VBA Step Into works as desired but running macro doesn't

    Hi smit.etha,

    Try the following (untested) additions in red:
    Private Sub Image1_Click()
    
        Application.ScreenUpdating = True
        
        If Application.WorksheetFunction.CountA(Range("B2:B5")) = 4 Then
            
        ActiveSheet.PageSetup.LeftFooter = Format(Now, "yyyy.mmm.dd HH:MM")
    
        Sheets("Temp Logger|GPS Setup").Select
      
        ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\Ethan\Desktop\" & Sheets("Temp Logger|GPS Setup").Range("A1") & ".pdf", Quality:=xlQualityStandard,     IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
          
        Else
        
        Shapes("Dennis").Visible = msoTrue
        Application.ScreenUpdating = True    
    
        Application.Wait (Now + TimeValue("00:00:05"))
          
        Shapes("Dennis").Visible = msoFalse
        Application.ScreenUpdating = True    
            
        End If
        
    End Sub
    Lewis

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,246

    Re: VBA Step Into works as desired but running macro doesn't

    Try putting a "DoEvents" just above your " Else" line
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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. Macro almost works. Does not Delete as desired
    By yuenk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2014, 09:51 AM
  2. Macro works during Step Into but not when fully run
    By LLL0422 in forum Excel Programming / VBA / Macros
    Replies: 45
    Last Post: 06-06-2014, 04:57 AM
  3. [SOLVED] Macro works in step through but not when run
    By bruizer31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 05:50 PM
  4. [SOLVED] preventing simple zoom macro from running step by step
    By reece1984 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-11-2012, 06:13 AM
  5. Workbook protection macro only works on step thru
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2010, 06:55 PM
  6. Macro run fails, step through works.
    By SteveAlston in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2009, 11:37 PM
  7. [SOLVED] running macro step by step different from normal run??
    By Rinze Smit in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-26-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