gyetvaig

VBA Selection restricted on a sheet

Jan 16th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' ----------------------------------------------------------------
  2. ' Purpose: Check if selection is restricted on a sheet in any way
  3. ' ----------------------------------------------------------------
  4. Function f_allSelectionEnabled(sh As Worksheet) As Boolean
  5.    
  6.     'If the sheet is not protected OR sheet is protected but EnableSelection is xlNoRestrictions returns True, otherwise False
  7.    If sh.ProtectContents = False Or (sh.ProtectContents = True And sh.EnableSelection = xlNoRestrictions) Then
  8.         f_allSelectionEnabled = True
  9.     Else
  10.         f_allSelectionEnabled = False
  11.     End If
  12.    
  13. End Function
Advertisement