![]() |
Inconsistent macro behavior
Can anyone tell me why this macro turns on the gridline display on some
worksheets, but not others, in the workbook? It's supposed to show all sheets, unprotect all sheets, and turn on gridlines on all sheets. Sub AllSheetsUnhideUnProtectWGrid() 'for all sheets in currently active workbook, assigned to button 'Password Dim WkSht As Worksheet Dim PWORD As String PWORD = "dave" Application.ScreenUpdating = False For Each WkSht In ActiveWorkbook.Worksheets If Not WkSht.Visible Then WkSht.Visible = True End If WkSht.Unprotect Password:=PWORD ActiveWindow.DisplayGridlines = True Next WkSht Application.ScreenUpdating = True End Sub As always, thanks in advance! |
Inconsistent macro behavior
Sub AllSheetsUnhideUnProtectWGrid()
'for all sheets in currently active workbook, assigned to button 'Password Dim WkSht As Worksheet Dim PWORD As String PWORD = "dave" Application.ScreenUpdating = False For Each WkSht In ActiveWorkbook.Worksheets If Not WkSht.Visible Then WkSht.Visible = True End If Wksht.Activate WkSht.Unprotect Password:=PWORD ActiveWindow.DisplayGridlines = True Next WkSht Application.ScreenUpdating = True End Sub -- Regards, Tom Ogilvy "davegb" wrote in message ups.com... Can anyone tell me why this macro turns on the gridline display on some worksheets, but not others, in the workbook? It's supposed to show all sheets, unprotect all sheets, and turn on gridlines on all sheets. Sub AllSheetsUnhideUnProtectWGrid() 'for all sheets in currently active workbook, assigned to button 'Password Dim WkSht As Worksheet Dim PWORD As String PWORD = "dave" Application.ScreenUpdating = False For Each WkSht In ActiveWorkbook.Worksheets If Not WkSht.Visible Then WkSht.Visible = True End If WkSht.Unprotect Password:=PWORD ActiveWindow.DisplayGridlines = True Next WkSht Application.ScreenUpdating = True End Sub As always, thanks in advance! |
Inconsistent macro behavior
Thanks Tom!
Tom Ogilvy wrote: Sub AllSheetsUnhideUnProtectWGrid() 'for all sheets in currently active workbook, assigned to button 'Password Dim WkSht As Worksheet Dim PWORD As String PWORD = "dave" Application.ScreenUpdating = False For Each WkSht In ActiveWorkbook.Worksheets If Not WkSht.Visible Then WkSht.Visible = True End If Wksht.Activate WkSht.Unprotect Password:=PWORD ActiveWindow.DisplayGridlines = True Next WkSht Application.ScreenUpdating = True End Sub -- Regards, Tom Ogilvy "davegb" wrote in message ups.com... Can anyone tell me why this macro turns on the gridline display on some worksheets, but not others, in the workbook? It's supposed to show all sheets, unprotect all sheets, and turn on gridlines on all sheets. Sub AllSheetsUnhideUnProtectWGrid() 'for all sheets in currently active workbook, assigned to button 'Password Dim WkSht As Worksheet Dim PWORD As String PWORD = "dave" Application.ScreenUpdating = False For Each WkSht In ActiveWorkbook.Worksheets If Not WkSht.Visible Then WkSht.Visible = True End If WkSht.Unprotect Password:=PWORD ActiveWindow.DisplayGridlines = True Next WkSht Application.ScreenUpdating = True End Sub As always, thanks in advance! |
All times are GMT +1. The time now is 08:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com