Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Busselton, Western Australia, Australia
    Posts
    59
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Behaviour different between "Running" and "Stepping" the code

    Hi,
    This is on Excel 2016.
    I have a procedure that I use to set up Excel so that the userform is displayed in front of a "Blank" excel page, i.e. no menus, no lines etc...
    The strange thing is that when I run the code (shown below) it only seems to action the code down to the with statement, anything after that seems to get ignored.
    When I step through the code, everything works as expected.
    I have set a break point within the the With/End With section to make sure the code is going there... and it is.
    Why would this code work when stepping the code through and not when "Running" the code?
    Appreciate any help that can be offered.
    Brian.

    Private Sub SetupDisplay()
    'Setup the display to have Excel 'Full Screen', no lines or page breaks displayed.
    'Move screen view to vacant area of spreadsheet so as to leave background clear
    Unprotect_Worksheet
    Application.DisplayFullScreen = True
    Application.DisplayFormulaBar = False
    ActiveSheet.DisplayPageBreaks = False
    ActiveWindow.DisplayWorkbookTabs = False
    With ActiveWindow
    .DisplayGridlines = False
    .DisplayHeadings = False
    End With
    ActiveWindow.LargeScroll ToRight:=1
    Application.ScreenUpdating = False


    End Sub

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,176
    Thanks
    47
    Thanked 982 Times in 912 Posts
    What happens if you change the "with" to straight lines - you have done that around them so they aren't needed?
    ActiveWindow.DisplayGridlines = False
    ActiveWindow.DisplayHeadings = False

    cheers, Paul

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Brian,

    The status of Application.ScreenUpdating is undetermined upon entrance to the subroutine shown. Since the changes you are making in the With Block require you allow updating to equal True place a ScreenUpdating = True just before the one you have setting it to False.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  4. #4
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,633
    Thanks
    115
    Thanked 647 Times in 590 Posts
    Seems as though the application.screenupdating=False should be at the beginning of the code, not the end. The code should also end with application.screenupdating= True to show the changes made (although not needed as the screen will update by default)

    Code:
    Private Sub SetupDisplay()
     'Setup the display to have Excel 'Full Screen', no lines or page breaks displayed.
     'Move screen view to vacant area of spreadsheet so as to leave background clear 
        Unprotect_Worksheet
        Application.ScreenUpdating = False
        Application.DisplayFullScreen = True
        Application.DisplayFormulaBar = False
        ActiveSheet.DisplayPageBreaks = False
        ActiveWindow.DisplayWorkbookTabs = False
        With ActiveWindow
            .DisplayGridlines = False
            .DisplayHeadings = False
        End With
        ActiveWindow.LargeScroll ToRight:=1
        Application.ScreenUpdating = True
     End Sub
    HTH,
    Maud
    Last edited by Maudibe; 2016-10-27 at 18:43.

  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Location
    Busselton, Western Australia, Australia
    Posts
    59
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Hi Everyone,
    Thanks for your input.
    The screen updating trick worked to solve the problem.
    Regards
    Brian.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •