Vba help remove gridlines

Hiport

Active Member
Joined
May 9, 2008
Messages
455
Hi, i want to remove gridlines from all worksheets, i ran a macro but the macro gave me activewindow, how can i get the code to run through all worksheets

.DisplayGridlines = False
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Code:
Sub nogrids()
    For Each Sheet In Sheets
       Sheet.Activate
       ActiveWindow.DisplayGridlines = False
    Next Sheet
End Sub
 
Upvote 0
Ok, can the below be amdended so that all gridlines to be removed for all sheets after sheet Rawdata

Code:
Sub nogrids()
    For Each Sheet In Sheets
       Sheet.Activate
       ActiveWindow.DisplayGridlines = False
    Next Sheet
End Sub
 
Upvote 0
To take the grid off of all sheets except Rawdata:
Code:
Sub nogridsexceptdata()
    For Each Sheet In Sheets
       If Sheet.Name <> "Rawdata" Then
          Sheet.Activate
          ActiveWindow.DisplayGridlines = False
       End If
    Next Sheet
End Sub
or to take the grid off of all sheets AFTER (to the right of) Rawdata
Code:
Sub nogridspastdata()
shcount = Sheets.Count
datacount = Sheets("Rawdata").Index
    For i = datacount + 1 To shcount
          Sheets(i).Activate
          ActiveWindow.DisplayGridlines = False
    Next i
End Sub
 
Upvote 0
I like jproffer's better, as it doesn't bother running thru the sheets up to/inclusive of RawData. Just in case you are already using a For Each...

<font face=Courier New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN><br>    <br><SPAN style="color:#00007F">Sub</SPAN> exa()<br><SPAN style="color:#00007F">Dim</SPAN> wks <SPAN style="color:#00007F">As</SPAN> Worksheet<br><SPAN style="color:#00007F">Dim</SPAN> wksCurrent <SPAN style="color:#00007F">As</SPAN> Worksheet<br><SPAN style="color:#00007F">Dim</SPAN> bolRightOfRawData <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN><br>    <br>    <SPAN style="color:#00007F">Set</SPAN> wksCurrent = ActiveSheet<br>    <br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> wks <SPAN style="color:#00007F">In</SPAN> Worksheets<br>        <SPAN style="color:#00007F">If</SPAN> bolRightOfRawData <SPAN style="color:#00007F">Then</SPAN><br>            wks.Select<br>            ThisWorkbook.Windows(1).DisplayGridlines = <SPAN style="color:#00007F">False</SPAN><br>        <SPAN style="color:#00007F">Else</SPAN><br>            bolRightOfRawData = wks.Name = "RawData"<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN><br>    wksCurrent.Select<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Mark
 
Upvote 0
Thanks this works

To take the grid off of all sheets except Rawdata:
Code:
Sub nogridsexceptdata()
    For Each Sheet In Sheets
       If Sheet.Name <> "Rawdata" Then
          Sheet.Activate
          ActiveWindow.DisplayGridlines = False
       End If
    Next Sheet
End Sub
or to take the grid off of all sheets AFTER (to the right of) Rawdata
Code:
Sub nogridspastdata()
shcount = Sheets.Count
datacount = Sheets("Rawdata").Index
    For i = datacount + 1 To shcount
          Sheets(i).Activate
          ActiveWindow.DisplayGridlines = False
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,644
Messages
6,125,993
Members
449,279
Latest member
Faraz5023

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top