+ Reply to Thread
Results 1 to 4 of 4

Strange behavior from some simple VBA code

  1. #1
    Registered User
    Join Date
    04-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    9

    Strange behavior from some simple VBA code

    Hi

    I have a simple 2 line VBA code which unhides a sheet then selects it.

    Problem is it `appears` to open it twice !!!

    The sheet is displayed, then all the shapes etc. flicker off than back on again.......strange thing is it doesn`t seem to happen the very first time the code is run, but does thereafter.
    Please Login or Register  to view this content.
    Any ideas ???

    Thanks

    Calibra
    Last edited by Paul; 04-25-2012 at 02:56 PM. Reason: Added CODE tags for user. Please do so yourself in the future.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Strange behavior from some simple VBA code

    Hi Calibra,

    Have you tried adding "Application.ScreenUpdating" before and after the sheet un-hiding process?
    Please Login or Register  to view this content.
    With only a few objects the re-draw isn't noticeable, but with many it definitely is (without the screenupdating turned off).

  3. #3
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Strange behavior from some simple VBA code

    could you attach dummy workbook ?

    consider to use:
    Please Login or Register  to view this content.
    -1 for xlSheetVisible
    0 for xlSheetHidden
    2 for xlSheetVeryHidden
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  4. #4
    Registered User
    Join Date
    04-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Strange behavior from some simple VBA code

    Quote Originally Posted by Paul View Post
    Hi Calibra,

    Have you tried adding "Application.ScreenUpdating" before and after the sheet un-hiding process?
    Please Login or Register  to view this content.
    With only a few objects the re-draw isn't noticeable, but with many it definitely is (without the screenupdating turned off).
    Brilliant !!! Worked perfectly.......Thanks
    I actually really enjoy VBA in excel, is there a good resource with sample code.......hopefully free !!

    Thanks again

    P.S. Could you look at my post Stopping movement of shapes excel 2010....maybe you could help
    Last edited by calibra; 04-25-2012 at 04:49 PM. Reason: added info

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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