+ Reply to Thread
Results 1 to 10 of 10

Removing GRIDLINES from one sheet to another sheet without activating the sheet using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Removing GRIDLINES from one sheet to another sheet without activating the sheet using VBA

    Removing GRIDLINES from one sheet to another sheet without activating the sheet using VBA

    Hi I know how to remove the Gridlines from the Active Sheet and also manually by going in the View Gridlines - Uncheck however, I am now pasting the data from one sheet to another and I want to actually do two things if possible..

    1. Copy the Gridline Condition from the Parent Sheet to the Value Sheet , like the if the Parent SHeet has no gridlines if it has no GRIDLINES then the Child or the Copied Sheet should also not have any GRIDLINES.

    2. Simply put no GRIDLINES command when pasting the data in the CHILD sheet using a MACRO.

    Warm Regards
    e4excel

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    The best I can figure is that the worksheet has to be active to turn off the gridlines.

    When active you can use:

    ActiveWindow.DisplayGridlines = False
    To find out if a worksheets has its gridlines on or off, again it needs to be active.
        Dim bOn As Boolean
        bOn = ActiveWindow.DisplayGridlines

  3. #3
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    Hey Steven Thanks again but I know of this, is it possible to use the Gridlines Value of TRUE or FALSE from one sheet to another?
    If I dont go to the SHeet and just create it with a macro ofcourse I am using your earlier help in doing this..then how do I do this..

    ALso , please can you please help me on my other query on getting the information on Borders the way you helped me get the numeric values for Font.Color in a new thread i just posted

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    Windows(2).DisplayGridlines = Windows(1).DisplayGridlines
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    Quote Originally Posted by shg View Post
    Windows(2).DisplayGridlines = Windows(1).DisplayGridlines
    Hi SHG, Thanks I was actually looking for this type of code but what do I replace the (02) and (1) with?
    I tired the actual Sheet Names it didn't work I stuck with the same things that didn't work too.

  6. #6
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    Re:
    Windows(2).DisplayGridlines = Windows(1).DisplayGridlines
    You have to activate both sheets as a separate window for this to work.

    For example:



    ActiveWindow.NewWindow
    Windows(2).Application.Workbooks(1).Worksheets("Sheet3").Activate
    Windows(1).Application.Workbooks(1).Worksheets("Sheet1").Activate
    Windows(2).DisplayGridlines = Windows(1).DisplayGridlines
    (But I like my idea better.)

  7. #7
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    I think I have also liked your idea better though the other method also looks good..
    But I am not able to understand how to use the same..
    I am extending from your help in my last thread ..
    What you had done was
    
    Sub GetFormatting()
    
        Cells.Select
        Selection.Clear
        Selection.NumberFormat = "@"
        ActiveWindow.DisplayGridlines = False -- This is to Hide the Gridlines in the Sheet Formatting
        
        Dim nRow As Long, nCol As Long, nLastCol As Long, nLastRow As Long, i As Long
        Dim wsR As Worksheet, wsF As Worksheet, wsD As Worksheet
        
        Set wsR = Worksheets("Report") -- Sheet from where I need to check whether the GRIDLINES are Displayed or NOT?
        Set wsF = Worksheets("Formatting")
        Set wsD = Worksheets("Dump") -- Sheet where I need the GRIDLINES to be the same as the REPORT SHeet

    I am not going to the Sheet "Dump" and I am trying to remotely control the formatting with the information i got in the Sheet Formatting..

    So how do I use the
        Dim bOn As Boolean
        bOn = ActiveWindow.DisplayGridlines

  8. #8
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    Dim bGridlines As Boolean
    
    '...
     
    Set wsR = Worksheets("Report")
    Set wsD = Worksheets("Dump")
    
    wsR.Activate
    bGridlines = ActiveWindow.DisplayGridlines
    wsD.Activate
    ActiveWindow.DisplayGridlines = bGridlines
    The point is that you have to activate the worksheet in order to get the setting.
    And you have to activate the worksheet in order to set the setting.
    bGridlines is just a variable where you store the value between the two activations.

  9. #9
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    Thanks Steven,
    I successfully managed to get the results using your approach thanks a lot for the explanation.

    Dear SHG,
    Please elaborate in the context of the existing code, how would i be able to use your code because I want to understand both the options even though my task is achieved.
    My intention was to actually not activate the sheets and still be able to change the GRIDLINES from Viewable to HIDDEN from the parent sheet.
    Please refer post# 7 to modify the approach..

    Thanks in advance SHG..
    Last edited by e4excel; 06-19-2012 at 03:25 AM.

  10. #10
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Removing GRIDLINES from one sheet to another sheet without activating the sheet using

    Dear SHG,

    I am closing the THREAD as SOLVED but would appreciate if you help with the last doubt..

    Thanks in advance..

+ 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