+ Reply to Thread
Results 1 to 13 of 13

Turn off all sheet gridlines without using ws.select?

  1. #1
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Talking Turn off all sheet gridlines without using ws.select?

    Hello!

    I don't like having the gridlines on when I use the workbook, but I do when creating. This code runs through the workbook and turns off all the gridlines (similar code for turning them on).

    Anyway, it has a ws.select line to jump to each sheet. This makes the screen flicker all over the place, plus the cursor winds up somewhere else (another sheet) than the cursor started.

    Can this code be made better to not use ws.select and still take care of all the sheets?

    Please Login or Register  to view this content.
    I appreciate the help!

    Respectfully,

    Lost
    Last edited by leaning; 06-09-2011 at 09:43 AM. Reason: Solved!

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Turn off all sheet gridlines without using ws.select?

    Maybe this will work
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Turn off all sheet gridlines without using ws.select?

    you can always turn off screen updating to disable the flickering:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Turn off all sheet gridlines without using ws.select?

    Or, you can add this to the beginning of your code:
    Please Login or Register  to view this content.
    and then this to the end
    Please Login or Register  to view this content.
    Doing it this way will remove the flickering. Use it wherever
    you have .Select or .Activate within your code.

  5. #5
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: Turn off all sheet gridlines without using ws.select?

    Mordred,

    I like your sheet counter idea.

    I put your code behind a button, but it doesn't seem to be doing anything.

    Am I missing something?

    Respectfully,

    Lost
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Turn off all sheet gridlines without using ws.select?

    Try this one:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Turn off all sheet gridlines without using ws.select?

    Try this
    Please Login or Register  to view this content.
    Last edited by royUK; 06-08-2011 at 03:17 PM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Turn off all sheet gridlines without using ws.select?

    @RoyUK, Isn't it possible to do this without actually selecting the sheets?

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Turn off all sheet gridlines without using ws.select?

    By selecting the sheets it creates a Group, then changing the view on the active sheet the others grouped are changed.

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Turn off all sheet gridlines without using ws.select?

    Quote Originally Posted by Mordred View Post
    @RoyUK, Isn't it possible to do this without actually selecting the sheets?
    No - this is one of those rare occasions where you have to select, because you are dealing with a property of the window rather than the sheet.
    Remember what the dormouse said
    Feed your head

  11. #11
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: Turn off all sheet gridlines without using ws.select?

    All,

    Thanks for all the info! And I see some new stuff I can put in the original code that would make it better.

    The reason I posted the question is because one of the workbooks has a hidden sheet.

    When you run the Gridlines code, it fails with error 1004: WS Select Method. My first thought that maybe the code could be revised to not even do select, but from the discussion, it looks like that won't work.

    So, is the best way for the code to handle that sheet is to temporarily unhide it (make it visible, select it, change gridlines, and then make it not visible)? Or is there a better way?

    Respectfully,

    Lost
    Attached Files Attached Files

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Turn off all sheet gridlines without using ws.select?

    Depends if you want to remove gridlines from it. If not, then loop each sheet, if visible select it, then turn off gridlines.

  13. #13
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Talking Re: Turn off all sheet gridlines without using ws.select?

    All,

    I appreciate everyone's help! This is the code I ended up with to run through the workbook and turn gridlines off on all visible/unhidden sheets:

    Please Login or Register  to view this content.
    Good stuff!

    Thanks and props to everyone who came to my aid.

    Respectfully,

    Lost

+ 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