+ Reply to Thread
Results 1 to 5 of 5

Setting background color with VBA removes gridlines -- how to bring back

Hybrid View

chasdl Setting background color with... 02-09-2013, 02:32 PM
shg Re: Setting background color... 02-09-2013, 02:34 PM
chasdl Re: Setting background color... 02-10-2013, 05:01 PM
shg Re: Setting background color... 02-10-2013, 05:04 PM
chasdl Re: Setting background color... 02-10-2013, 05:27 PM
  1. #1
    Registered User
    Join Date
    02-09-2013
    Location
    Plano, TX
    MS-Off Ver
    Excel 2010
    Posts
    3

    Setting background color with VBA removes gridlines -- how to bring back

    Hi Folks,

    Glad you guys are here and thanks so much for any help.... I'm using Excel 2010 on a Windows XP SP3 system.

    I've discovered that using VBA to set the background color on a range of cells in a worksheet also wipes out the gridlines. My questions are two fold. First, how can I bring those gridlines back once they have been wiped out? I notice that the global "Gridlines" option has no effect on the range that has been cleared through VBA. And second, is there any way to use VBA to change the color of a cell in a way that does not affect the gridlines? I need the ability to mark certain cells through VBA in a way that preserves the gridlines.

    Thanks, and best to all....

  2. #2
    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: Setting background color with VBA removes gridlines -- how to bring back

    Gridlines only appear when cells have no fill, so no. The fill doesn't remove them, it covers them.

    You can use borders.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-09-2013
    Location
    Plano, TX
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Setting background color with VBA removes gridlines -- how to bring back

    Thanks for the response... That actually answered one of my questions but raised another. Since you mentioned that the background color only covers the gridlines, I was able to make them come back visually by setting the color index to xlColorIndexNone. Worked fine, and I know how to handle that problem in the future.

    However, I am unfamiliar with using borders in VBA... Can you elucidate a little on that? For example, how do we set or remove borders from a cell using VBA?

    Thanks...

  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: Setting background color with VBA removes gridlines -- how to bring back

    Try recording a macro, and post back if you get stuck.

  5. #5
    Registered User
    Join Date
    02-09-2013
    Location
    Plano, TX
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Setting background color with VBA removes gridlines -- how to bring back

    Okay, will do...

+ 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