opinionated86
New Member
- Joined
- Feb 2, 2016
- Messages
- 12
Hi
I've got a spreadsheet that several people use, some of them regularly hide columns to make it easier to look at while they work, the problem is the forget to unhide the columns once they're done, I've figured out how to stop this with a 'Workbook_BeforeSave' private sub that unhides all columns but now these same colleagues are finding more bizarre ways to get round this like squashing the column width down to zero, what i want is to make it so that if they have hidden columns they get asked before saving if they want to unhide them, hopefully this extra prompt will get them to remember to unhide on their final save when they're done, the code below is what I've got so far, i don't want the prompt to come up if there aren't any hidden columns as then it's just a pain to everyone and more likely to get ignored.
I've tried a few other things like:
But this only works on the first column specified. Any help would be very much appreciated.
I've got a spreadsheet that several people use, some of them regularly hide columns to make it easier to look at while they work, the problem is the forget to unhide the columns once they're done, I've figured out how to stop this with a 'Workbook_BeforeSave' private sub that unhides all columns but now these same colleagues are finding more bizarre ways to get round this like squashing the column width down to zero, what i want is to make it so that if they have hidden columns they get asked before saving if they want to unhide them, hopefully this extra prompt will get them to remember to unhide on their final save when they're done, the code below is what I've got so far, i don't want the prompt to come up if there aren't any hidden columns as then it's just a pain to everyone and more likely to get ignored.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Columns.Hidden = True Then
If MsgBox("Do you want to unhide any hidden cells?", vbYesNo) = vbYes Then
Columns.Hidden = False
End If
End If
End Sub
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheets("Master").Range("A:AU").EntireColumn.Hidden Then
If MsgBox("Do you want to unhide any hidden cells?", vbYesNo) = vbYes Then
Columns.Hidden = False
End If
End If
End Sub