PC Review


Reply
Thread Tools Rate Thread

display gridlines

 
 
Steve
Guest
Posts: n/a
 
      13th Oct 2009
Morning all.
I have multiple worksheets that are displaying the gridlines. This appears
to be fairly common across numerous workbooks, so I'd like to make a macro
that will turn off the display gridlines.
I recorded a macro that turned off the grid lines for a single worksheet,
now I need to put in a for loop to iterate through all of the sheets in the
file.
I tried the following and it hangs up on the "If sh.DisplayGridlines = True
Then" statement, stating it cannot perform this task-- "object does not
support this property or method" a 438 error.
Any ideas on how to make one that does work?
Thank you.

Sub Grids()
'
' grids Macro
' turn off grid lines
'
For Each sh In ActiveWorkbook.Worksheets
If sh.DisplayGridlines = True Then
sh.DisplayGridlines = False

End If
Next
' ActiveWindow.DisplayGridlines = False

End Sub

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      13th Oct 2009
DisplaygridLines is a member of windows not a worksheet

ActiveWorkbook.Windows(1).DisplayGridlines = True

"Steve" wrote:

> Morning all.
> I have multiple worksheets that are displaying the gridlines. This appears
> to be fairly common across numerous workbooks, so I'd like to make a macro
> that will turn off the display gridlines.
> I recorded a macro that turned off the grid lines for a single worksheet,
> now I need to put in a for loop to iterate through all of the sheets in the
> file.
> I tried the following and it hangs up on the "If sh.DisplayGridlines = True
> Then" statement, stating it cannot perform this task-- "object does not
> support this property or method" a 438 error.
> Any ideas on how to make one that does work?
> Thank you.
>
> Sub Grids()
> '
> ' grids Macro
> ' turn off grid lines
> '
> For Each sh In ActiveWorkbook.Worksheets
> If sh.DisplayGridlines = True Then
> sh.DisplayGridlines = False
>
> End If
> Next
> ' ActiveWindow.DisplayGridlines = False
>
> End Sub
>

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      13th Oct 2009
Do not test:

Sub NoGrid()
Dim s As Worksheet
For Each s In Sheets
s.Activate
ActiveWindow.DisplayGridlines = False
Next
End Sub

--
Gary''s Student - gsnu200907


"Steve" wrote:

> Morning all.
> I have multiple worksheets that are displaying the gridlines. This appears
> to be fairly common across numerous workbooks, so I'd like to make a macro
> that will turn off the display gridlines.
> I recorded a macro that turned off the grid lines for a single worksheet,
> now I need to put in a for loop to iterate through all of the sheets in the
> file.
> I tried the following and it hangs up on the "If sh.DisplayGridlines = True
> Then" statement, stating it cannot perform this task-- "object does not
> support this property or method" a 438 error.
> Any ideas on how to make one that does work?
> Thank you.
>
> Sub Grids()
> '
> ' grids Macro
> ' turn off grid lines
> '
> For Each sh In ActiveWorkbook.Worksheets
> If sh.DisplayGridlines = True Then
> sh.DisplayGridlines = False
>
> End If
> Next
> ' ActiveWindow.DisplayGridlines = False
>
> End Sub
>

 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      13th Oct 2009
Scaratch my request.
I got it.

Sub Grids()
'The purpose of this macro is to turn off grid lines on all worksheets
' in the file.
For i = 1 To Sheets.Count
With ActiveWindow
If .DisplayGridlines = True Then
.DisplayGridlines = False

End If
End With
Next
' ActiveWindow.DisplayGridlines = False

End Sub

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      13th Oct 2009
Try it this way (it will hide the process from the user and keep the current
worksheet active)....

Sub TurnGridLinesOff()
Dim WS As Worksheet, SN As String
Application.ScreenUpdating = False
SN = ActiveSheet.Name
For Each WS In Worksheets
WS.Activate
ActiveWindow.DisplayGridlines = False
Next
Worksheets(SN).Activate
Application.ScreenUpdating = True
End Sub

--
Rick (MVP - Excel)


"Steve" <(E-Mail Removed)> wrote in message
news:14C180E3-1560-42AA-87A2-(E-Mail Removed)...
> Morning all.
> I have multiple worksheets that are displaying the gridlines. This appears
> to be fairly common across numerous workbooks, so I'd like to make a macro
> that will turn off the display gridlines.
> I recorded a macro that turned off the grid lines for a single worksheet,
> now I need to put in a for loop to iterate through all of the sheets in
> the
> file.
> I tried the following and it hangs up on the "If sh.DisplayGridlines =
> True
> Then" statement, stating it cannot perform this task-- "object does not
> support this property or method" a 438 error.
> Any ideas on how to make one that does work?
> Thank you.
>
> Sub Grids()
> '
> ' grids Macro
> ' turn off grid lines
> '
> For Each sh In ActiveWorkbook.Worksheets
> If sh.DisplayGridlines = True Then
> sh.DisplayGridlines = False
>
> End If
> Next
> ' ActiveWindow.DisplayGridlines = False
>
> End Sub
>


 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      13th Oct 2009
Thanks Rick,
It appears mine didn't work after all..... sigh... one day when I grow up, I
want to know how to program..... whine.......
Yours works......


"Rick Rothstein" wrote:

> Try it this way (it will hide the process from the user and keep the current
> worksheet active)....
>
> Sub TurnGridLinesOff()
> Dim WS As Worksheet, SN As String
> Application.ScreenUpdating = False
> SN = ActiveSheet.Name
> For Each WS In Worksheets
> WS.Activate
> ActiveWindow.DisplayGridlines = False
> Next
> Worksheets(SN).Activate
> Application.ScreenUpdating = True
> End Sub
>
> --
> Rick (MVP - Excel)
>
>
> "Steve" <(E-Mail Removed)> wrote in message
> news:14C180E3-1560-42AA-87A2-(E-Mail Removed)...
> > Morning all.
> > I have multiple worksheets that are displaying the gridlines. This appears
> > to be fairly common across numerous workbooks, so I'd like to make a macro
> > that will turn off the display gridlines.
> > I recorded a macro that turned off the grid lines for a single worksheet,
> > now I need to put in a for loop to iterate through all of the sheets in
> > the
> > file.
> > I tried the following and it hangs up on the "If sh.DisplayGridlines =
> > True
> > Then" statement, stating it cannot perform this task-- "object does not
> > support this property or method" a 438 error.
> > Any ideas on how to make one that does work?
> > Thank you.
> >
> > Sub Grids()
> > '
> > ' grids Macro
> > ' turn off grid lines
> > '
> > For Each sh In ActiveWorkbook.Worksheets
> > If sh.DisplayGridlines = True Then
> > sh.DisplayGridlines = False
> >
> > End If
> > Next
> > ' ActiveWindow.DisplayGridlines = False
> >
> > End Sub
> >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display of gridlines Financeguy Microsoft Excel Programming 2 20th Jul 2009 02:54 PM
display gridlines with fill color smartgal Microsoft Excel Misc 1 24th Jan 2009 01:54 AM
gridlines won't display bobm Microsoft Excel Misc 1 6th Dec 2008 06:15 PM
my excel worksheet will not display gridlines =?Utf-8?B?am9tYmE=?= Microsoft Excel Worksheet Functions 3 27th Jul 2007 08:02 AM
How to display gridlines at irregular intervals? Jason Weiss Microsoft Excel Charting 2 3rd Jan 2005 07:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:33 PM.