J
Jan Nademlejnsky
I need to "clean up" each sheet in the spreadsheet before it is saved. I am
using the routine which was suggested on this site. I am getting error when
trying to unhide rows and columns. The rows and columns might not be hidden
in the first place. Just in case that someone hid any row or columns I want
to unhide them for the next user. I need to fix the syntax, please:
Dim wks As Worksheet
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
For Each wks In ActiveWorkbook.Worksheets
With wks
.Unprotect
Cells.Select
Selection.EntireRow.Hidden = False
Selection.EntireColumn.Hidden = False
Range("B2").Select
.AutoFilterMode = False
Application.Goto reference:=.Range("A1"), Scroll:=True
.Range("a3").Select
.Protect
End With
Next wks
Sheets("sheet1").Select 'Goes to first sheet
Range("a3").Select
End Sub
Thanks
Jan
using the routine which was suggested on this site. I am getting error when
trying to unhide rows and columns. The rows and columns might not be hidden
in the first place. Just in case that someone hid any row or columns I want
to unhide them for the next user. I need to fix the syntax, please:
Dim wks As Worksheet
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
For Each wks In ActiveWorkbook.Worksheets
With wks
.Unprotect
Cells.Select
Selection.EntireRow.Hidden = False
Selection.EntireColumn.Hidden = False
Range("B2").Select
.AutoFilterMode = False
Application.Goto reference:=.Range("A1"), Scroll:=True
.Range("a3").Select
.Protect
End With
Next wks
Sheets("sheet1").Select 'Goes to first sheet
Range("a3").Select
End Sub
Thanks
Jan